SamiTech Code
341 subscribers
132 photos
12 videos
4 files
87 links
Computer Science student and software developer focused on building impactful products, exploring AI, and solving real-world challenges with technology.
My portfolio.... sami.pro.et

“Your efforts today are your goals tomorrow.”
Download Telegram
good night everyone🛏
Good morning family🙋
🥰1
🧑‍💻Study time you know that we're on the Python functions we tried to see some highlight of it. now we learn together python function Arguments
Hey guys my apologize! I forget to remind you as long as you're coding you must push your code to the github. So if you're not doing that right now go and create account on the github. and add, commit, push your code to it. https://github.com/login
1
SamiTech Code pinned «...My progress here👉🏾Python Functions: def my_func(): print("Hello this's a functions") my_func() #calling the functions my_func() #calling the functions my_func() #calling…»
GA guys☀️
Hey guys there were no light about starts from lunch time to about 2pm sorry for that matter🙇‍♂️ But recently it just came
Hey What I've learned today....🤔.👇 #Python function arguments:
A function can have arguments, which are values you can pass to the function when you call it.
#A function with one argument:
def greet(name):
return f"Hello, {name}!"
print(greet("Alice")) #greet(argument)

#A function with multiple arguments:
def add(a, b):
return a + b
print(add(4, 8))

#Parameter vs Argument: 👉🏾A parameter is a variable in the function definition that represents a value that will be passed to the function when it is called. 👉🏾An argument is the actual value that is passed to the function when it is called.
def my_function(para1, para2): #here parameter
return para1 + para2
result = my_function(5, 9) # 5 and 9 are arguments
print(result)

#positional only arguments:
you can specify that a function can have only positional argument
to specify a positional-only argument, add ', /' after the arguments
def my_function(name, /):
print("Hello", name)
# my_function(name = "Alice") # TypeError: my_function() got some positional-only arguments but keyword was given
my_function("Alice") #correct

#Keyword-only arguments:
# To specify that can have only keyword argument, add * , before arguments
def my_func(*, name):
print("Hello", name)
# my_func("John") # TypeError: my_func() take 0 positional arguments bu 1 was given
my_func(name = "John") #correct

...Oh 👆👆don't let to practice it not only this I'll send for you the others just for now this's enough ...PRACTICE BUILD SKILL😎 If you've any question you're welcome🫡
1
GN fam🫶
1
SamiTech Code pinned «Hey What I've learned today....🤔.👇 #Python function arguments: A function can have arguments, which are values you can pass to the function when…»
GM friends🌅

Are you study well with me? If you're, nice keep it up don't stop. For what we do, we have to have discipline. Keep going your today challenge's your tommorow success.👌

Stay focused, with our Machine Learning journey💪 Ask question, answer for the question posted in this channel. Don't leave it out to practice you may got something usefull.

And pls share this channel for your friends you may know, Cuz we've to grow, learn, share ideas together...👈 Thanks🙏
Q2.What is the correct keyword for defining functions in Python?
Anonymous Quiz
17%
function
83%
def
0%
defined
👍1
Hey guys Goodmorning
Hello family HRU all? how studying is going on just right now I've started Arbitrary keyword Arguments **kwargs...keep studying with me. Yup
Why we use **kwargs(**keyword arguments)? Cuz, it allows us to handle a variable number of keyword arguments, which can be useful when we want to create flexible
function that can accept different types of input without having to define a fixed number of parameters.
here code eg;👇
def my_func(**kwargs):
print("Type", type(kwargs))
print("Name: ", kwargs["name"])
print("Age: ", kwargs["age"])
print("All data: ", kwargs)
my_func(name = "Alice", age = 21, city = "New York", country = "USA")

city & country isn't passed as a key but since there is ** before the kwargs it can accept it. key point to understand: **kwargs collects all keyword arguments, Stored as a dictionary, Python converts this to:👇
kwargs = {
"name": "Alice",
"age": 21,
"city": "New York",
"country": "USA"
}
👏1
And now I've learned ... Combining *args and **kwargs
Before that, what is d/t between *args and **kwargs?
*args is used to pass a variable number of non-keyword arguments to a function,
while **kwargs is used to pass a variable number of keyword arguments to a function.

def student_info(student_id, *courses, **details):
print("Student ID: ", student_id)
print("Courses: ", courses)
print("Details: ", details)
student_info(101, "Math", "Cs", "IT", name = "Bob", age = 20, city = "AA")

Send the output of this👆inside of the comment section, share for us what you understand.👌
🔥1
Q3: keyword arguments are often called? Q4: If you do not know the number of arguments that will be passed into your function, there is a prefix you can add in the function definition, which prefix?👇
def my_function(_kids): # here'_' fill it?
print("The youngest child is " + kids[2])

And don't forget to push your code to the github🫡
🔥1
SamiTech Code pinned «Why we use **kwargs(**keyword arguments)? Cuz, it allows us to handle a variable number of keyword arguments, which can be useful when we want to create flexible function that can…»
Hey fam!, Have a nice sleep...🛏
Good morning everyones🌅