+ 1

how dose the variable x,y get defined as a,b without declaring it such as a=x b= y

21st Jul 2016, 12:34 PM
Wayne Gaebelein
Wayne Gaebelein - avatar
5 Respostas
+ 2
I see the above code as declaration. This is because python unlike JavaScript for instance does not prepend var to declare variables. In JavaScript: var a = x var b = y In python: a = x b = y The = operator is an assignment operator so python is smart to understand that, the item on the right should be a value to be put into the container of the item on the left, variable
21st Jul 2016, 1:47 PM
Benneth Yankey
Benneth Yankey - avatar
+ 1
Python is cool so you can also the following: a,b = x,y
21st Jul 2016, 3:34 PM
Keola
Keola - avatar
+ 1
Using the Functions as Objects lesson. In that lesson x and y are variables of multiply (the function) when operation (the variable) is assigned to multiply (the function) operation = multiply then all atributes of multiply now apply to operation. Operation takes the variables of a and b already defined as 4, 7 and in the operation instance of multiply 4 and 7 now take the place of x and y.
26th Jul 2016, 7:31 AM
Kristopher Staples
Kristopher Staples - avatar
0
thanks that makes sense
21st Jul 2016, 2:15 PM
Wayne Gaebelein
Wayne Gaebelein - avatar
0
they cant
29th Jul 2016, 10:19 PM
Narek Tonoyan
Narek Tonoyan - avatar