In: Computer Science
In IDLE - Python 3, do the following:
1.
Create File --> New
2. Enter the code below in the new file (you may omit the comments,
I included them for explanation
#Python Code Begin
x = int(input("Enter a
number: "))
y = int(input("Enter
another number: "))
print ("Values before", "x:", x, "y:", y)
#add code to swap
variables here
#you may not use
Python libraries or built in swap functions
#you must use only the
operators you have learned to use in this class so
far
#you may use
additional variables if you wish
print ("Values after ", "x:", x, "y:", y)
#Python Code End
3. File -->Save --> name the M5_FML_Tinker1.py
4. Run --> Run Module
Input: 5 6
Output:
Enter
a number: 5
Enter another number: 6
Values before x: 5 y: 6
Values after x: 6 y: 5
Submission:
1. At the top of your Python code, add a comment with your name at the top of the file
# FirstName LastName
2. Run it one more time to make sure you did not "break" the code.
3. Upload the M5_FML_Tinker.py file
Python program :
M5_FML_Tinker.py :
#Python Code Begin #asking user to enter a number x = int(input("Enter a number: ")) #asking user to enter another number y = int(input("Enter another number: ")) #print the values of x and y print ("Values before", "x:", x, "y:", y) newVariable=x #storing value of x into newVariable x=y #storing value of y into variable x y=newVariable #storing value of newVariable into y #print the values of x and y print ("Values after ", "x:", x, "y:", y) #Python Code End
**************************************
Please refer to the screenshot of the code to understand the indentation of the code :
**************************************
Output :