+ 1
Difference of "def func(x) and def func ()"
Aside from the spellings, are there any? While I code it often causes me an error or is it the arguments inside the func that causes it? I believe it was mentioned from a topic in Python but after proceeding to many lessons I can't quite remember. Thanks in advance for your response😊😊😊
2 Réponses
+ 2
def func(x):
#now we expect x and we will able to use x
x = x*x
print(x)
func(2) ==> 4
def func2():
# if we need to use any varible we have to assing it
x = 2*2
print(x)
func2() ==> 4
same result but second functions is not dynamic you had to assign values to variables.
+ 5
Well atleast when you define as "def func(x)", you must always pass one argument when you call the function.