Question: Problem 1: Variables Python Beginning with a Python program that defines three variables (x, y, and z) and gets their values from user input, write

Problem 1: Variables Python

Beginning with a Python program that defines three variables (x, y, and z) and gets their values from user input, write code that will "rotate" the value of the three variables. This means that x gets the old value of y, y gets the old value of z, and z gets the old value of x. For example, if x = 10, y = -7, and z = 21, then after executing your code, the values of the variables should be x = -7, y = 21, and z = 10. The program should work regardless of the initial values of x, y, and z (therefore, you probably should avoid having any numbers in the answer). Also, you should introduce no more than ONE additional variable in your program.

Template to start from:

print("Enter the first value: ", end="") x = int(input()) print("Enter the second value: ", end="") y = int(input()) print("Enter the third value: ", end="") z = int(input()) print("Original values: x={:d}, y={:d}, z={:d}".format(x, y, z)) # Write code to "rotate" values here # Do NOT change code for the print statements print("Rotated values: x={:d}, y={:d}, z={:d}".format(x, y, z))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!