teapawtteapawt
$
  • Timeline
  • Grid
  • Gallery
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar11 Apr 2024
In the code below is a Python function that take a list of numbers as an input and then filters out the prime numbers in the list.
Image from adada.py (@pythoncodestar)
1
1
88
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar21 Jun 2023
Similarly, the keyworded **kwargs arguments allows the user to pass a variable number of keyworded arguments to a function. For instance, you can pass a dictionary of arguments to a function and unpack them using **kwargs. Check the example below:
Image from adada.py (@pythoncodestar)
1
51
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar21 Jun 2023
Yes, *args and **kwargs allow for passing an unlimited number of arguments to a function in Python. The special syntax *args in function definitions in Python allows us pass a variable number of non-keyworded arguments to a function. Find an example below.
Image from adada.py (@pythoncodestar)
1
34
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar20 Jun 2023
Do you know there is dictionary comprehension in Python, which works just like list comprehension? It helps create a dictionary with one line of code. Take a look at these two code snippets. One uses traditional for loop and the other uses comprehension. Which one is easier?
Image from adada.py (@pythoncodestar)
Image from adada.py (@pythoncodestar)
2
96
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar19 Jun 2023
List comprehension is a game-changer in Python! With just one line of code, you can create, filter, and transform lists. Check these two examples; the first one the traditional way, the second one using list comprehension.
Image from adada.py (@pythoncodestar)
Image from adada.py (@pythoncodestar)
3
245
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar10 Apr 2023
When we call the add function, it will now log its inputs and outputs:
Image from adada.py (@pythoncodestar)
1
2
54
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar10 Apr 2023
Image from adada.py (@pythoncodestar)
1
1
66
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar21 Mar 2023
Python is rich in built-in methods for string manipulation. Here are a few examples
Image from adada.py (@pythoncodestar)
Image from adada.py (@pythoncodestar)
1
1
6
864
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar14 Mar 2023
My first web dev project with HTML, CSS, and @getbootstrap CSS, thanks to @yu_angela course
1
1
1
91
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar5 Mar 2023
I appreciate it sir @willmcgugan 🙏
Image from adada.py (@pythoncodestar)
73
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar1 Mar 2023
Based on @mathsppblog's advice, I have been playing around the Rich Python library. I must say it is truly rich! Below is a snippet:
Image from adada.py (@pythoncodestar)
1
2
13
2,825
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar28 Feb 2023
With the #colorama package you can actually print output in Python in your desired color as below
Image from adada.py (@pythoncodestar)
5
3
19
3,778
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar26 Feb 2023
Okay!
Image from adada.py (@pythoncodestar)
2
320
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar3 Feb 2023
First one walks you through the solution; second one makes life easy for you:)
Image from adada.py (@pythoncodestar)
Image from adada.py (@pythoncodestar)
1
3
1
6
379
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar2 Feb 2023
Replying to @driscollis
True. Two obvious benefits of using comprehension in this case are: 1. Comprehension is more readable; 2. Comprehension allows you to perform more complex operations in that single line of code, as in this example below
Image from adada.py (@pythoncodestar)
1
1
41
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar1 Feb 2023
Wow! This is massive for me. Thank you @mathsppblog
Image from adada.py (@pythoncodestar)
1
4
680
adada.py (@pythoncodestar) profile picture
adada.py@pythoncodestar1 Feb 2023
Dictionary comprehension is a concise way to create a dictionary in Python. Here's an example of how you can create a dictionary from two lists 👇👇👇 #100DaysOfCode #Python
Image from adada.py (@pythoncodestar)
1
13
53
7,733
Load more