Hi there ,
I am a newbie to programming and I am learning user defined functions.I am having particular difficulty with the functions below which relate to the caller in a series of functions.Your help would be much appreciated.
1.
2.
3.
I am a newbie to programming and I am learning user defined functions.I am having particular difficulty with the functions below which relate to the caller in a series of functions.Your help would be much appreciated.
1.
x = [1, 2, 3] def func(x): x[1] = 42 print(func(x)) # prints none print(x) #prints[1,42,3]I am right in saying that this function has no variables and x is being passed temporarily in this function because when func(x) is printed it returns none .The list changes because it is mutable.
2.
x = 4 def func(y): print(y) # prints 4 print(func(x)) print noneIs this similar to example 1 where x is being passed in func(y) and y has not variable.An object Y is created which point to 4 temporarily .
3.
x= 3 def func(x): x = 7 print (func(x)) # prints none print(x) # prints 3is this similar to the others in that this func(x) has not variable and executes none .