ipl-logo

Pt1420 Unit 6 Assignment

203 Words1 Pages
line from x = y to y = x. Mathematically, x = y and y = x mean the same thing. How- ever, this is not so in programming. Run the second program. You will now get x = 5 y = 5 You can see that in this example, the x value remains as 5, but the value of y is changed to 5. This is because the statement y = x assigns the value of x to y (y <- x). y becomes 5 while x remains unchanged as 5. Basic Operators Besides assigning a variable an initial value, we can also perform the usual mathe- matical operations on variables. Basic operators in Python include +, -, *, /, //, % and ** which represent addition, subtraction, multiplication, division, floor divi- sion, modulus and exponent respectively. Example: Suppose x = 5, y = 2 Addition:

More about Pt1420 Unit 6 Assignment

Open Document