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
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