0

Are parameters and variables same?

In the code below, I tried to define two parameters 'x' and 'y', where the user will input the value of numbers ( just like normal variables, but instead directly as arguments) i.e. when I call the function for user input, it shows the 'x' is not defined, but I have defined it as : int(input(enter a number: )). Could someone explain? Thank a ton :) https://code.sololearn.com/c4l1m7kU8VCa/?ref=app

27th Apr 2020, 12:20 AM
Aril Sirohi
Aril Sirohi - avatar
3 Answers
+ 3
Since you define the variables inside the function, there is no need for parameters. Try: def func(): #your function func() If you want to use parameters: def func(x,y): if x > y: print(x) ....... func(3,5) Since you define x as the first digit and y as the second, when you call the function with x and y replaced with values they replace them in the function
27th Apr 2020, 12:46 AM
Slick
Slick - avatar
+ 3
Why not try like this Fun(x=int(input()), y=int(input()))
27th Apr 2020, 12:54 AM
Peter Parker
Peter Parker - avatar
+ 2
Understood ! Thanks a lot !
27th Apr 2020, 12:56 AM
Aril Sirohi
Aril Sirohi - avatar