Programming Summary of While and For Loops Python
Programming Summary of While and For Loops Python
bruh
Saturday, 16 March 2024 21:18
FUNCTIONS ARE HELPFUL BRO, the beer is wearing off and now im sad again
result = add(3, 4) # Here, 3 and 4 are arguments passed to the function add
def greet(name="World"):
print("Hello,", name)
def multi_add(*args):
return sum(args)
double = lambda x: x * 2
result = double(5) # result will be 10
def greet(name):
"""Print a greeting message."""
print("Hello,", name)
greet("Nat") #Prints Hello, Nat
def foo():
x = 10
print(x)
# print(x) # This will raise a NameError because x is not defined in the global scope
x = 10
def foo():
global x
x += 1
print(x)
foo() # Outputs: 11