Focus mode
def hello(end, start = "Hello"):
print(start + " " + end)
hello("Denis")
Hello Denis
hello("Denis", start = "Hey")
Hey Denis
hello("Denis","Hey")
Hey Denis
hello("Denis")
Hello Denis
def power(x, y=1):
return x ** y
power(3)
3
power(4, 2)
16
# Aksini belirtmezsek predefined değerleri kullanacak fonksiyon
# predefined olarak vereceğimiz değerleri en sona yazmalıyız yoksa hata alırız
def hello(start = "Hello", end):
print(start + end)
File "<ipython-input-11-3e7ef8b7d5fb>", line 3
def hello(start = "Hello", end):
^
SyntaxError: non-default argument follows default argument
def f(x, y=1, z=2):
return x + y + z
f(2)
5
f(2,5)
9
f(2,5,6)
13
Programs to Accelerate Your Progress in a Software Career
Join our 4-8 month intensive Patika+ bootcamps, start with the fundamentals and gain comprehensive knowledge to kickstart your software career!
You need to enroll in the course to be able to comment!