Question

In: Computer Science

In IDLE - Python 3, do the following: 1. Create File --> New 2. Enter the...

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

Solutions

Expert Solution

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 :


Related Solutions

Create a Python script in IDLE or Kali Python3 CLI to create the following Python Program:...
Create a Python script in IDLE or Kali Python3 CLI to create the following Python Program: Your program will create a username of your choice using a Kali Linux command "useradd -m mark", then set the password for that user using the Kali Linux Command "echo "mark:10101111" | chpasswd". Then you create a dictionary file using the Kali Linux command "crunch 8 8 01 > mylist.txt" Your python script should crack the password for that user and display on the...
Write functions in Python IDLE that do the following: i) A function that takes 2 arguments...
Write functions in Python IDLE that do the following: i) A function that takes 2 arguments and adds them. The result returned is the sum of the parameters. ii) A function that takes 2 arguments and returns the difference, iii) A function that calls both functions in i) and ii) and prints the product of the values returned by both.
Please use python and run in IDLE Question 1 Write functions that do the following: i)...
Please use python and run in IDLE Question 1 Write functions that do the following: i) A function that takes 2 arguments and adds them. The result returned is the sum of the parameters. ii) A function that takes 2 arguments and returns the difference, iii) A function that calls both functions in i) and ii) and prints the product of the values returned by both. Question 2 Write functions: i) One that prompts a user for 2 numbers. ii)...
​​​​Python Create a new file named compute_cost.py. Write your name and date in a comment. Create...
​​​​Python Create a new file named compute_cost.py. Write your name and date in a comment. Create a variable named base_fee and set the value to 5.5. Prompt the user for the zone. The zones can be an integer value from 1 to any value for the zone. Convert the zone to an integer. Display the zone on the SenseHat with a scroll speed of 0.3, make the text blue, and the background yellow. Scroll "The zone is " and the...
Task 2: Debugging and writing functions In IDLE, use the File -> New Window menu option...
Task 2: Debugging and writing functions In IDLE, use the File -> New Window menu option to open a new editor window for your program, and save it using the name hw4Task2.py. Make sure to specify the .py extension. Copy the following (buggy) code into that file: def mysum(x, y) """ takes two numbers and returns their sum """     total = x + y     print(total) Save the file using Ctrl-S. Then try to run it using F5. What...
In Python, create a program with 2 classes that do the following. HashCreate class, this class...
In Python, create a program with 2 classes that do the following. HashCreate class, this class will accept a directory and hash each file in the directory and store the results in a dictionary. The dictionary will contain the hash value and file name. HashVerify, the second class will accept the dictionary as input and save that in an instance attribute. This class must also contain a method for lookups that require a file path as input. The lookup method...
python Create a new file name condition_quiz.py. Add a comment with your name and the date....
python Create a new file name condition_quiz.py. Add a comment with your name and the date. Prompt the user to enter the cost. Convert the input to a float. Prompt the user for a status. Convert the status to an integer Compute the special_fee based on the status. If the status is 0, the special_fee will be 0.03 of the cost. Else if the status is 1, the special_fee will be 0.04 of the cost. Else if the status is...
Python: IDLE exercise 1. Start by running, in the shell, the following assignment statement: s1 =...
Python: IDLE exercise 1. Start by running, in the shell, the following assignment statement: s1 = 'abcdefghijklmnopqrstuvwxyz' Now write expressions—on separate lines of code—using sting s1 and the indexing operator that evaluate to 'm', 'p', 'z', 'e', 'a'. 2. Write Python statements that correspond to the following: a. assign to variable flowers a list containing strings 'rose', 'bougainvillea', 'yucca', 'marigold', 'daylily', and 'lily of the valley'. b. Write Boolean expressions that evaluate to True if the string ‘carrot’ is in...
python Create a file named sales_bonus.py 2. Prompt the user for the amount of sales made,...
python Create a file named sales_bonus.py 2. Prompt the user for the amount of sales made, convert to a float, and assign to sales. 3. Prompt the user for number of days missed, covert to an int, and assign to days_missed 4. If the user have more than 3000 of sales and has missed less than or equal to two days of work, assign bonus to 100. 5.   Else if the user have more than 3000 of sales or has missed...
2.13 Program: Food receipt (Python 3) 1.Enter food item name: hot dog Enter item price: 2...
2.13 Program: Food receipt (Python 3) 1.Enter food item name: hot dog Enter item price: 2 Enter item quantity: 5 RECEIPT 5 hot dog @ $ 2.0 = $ 10.0 Total cost: $ 10.0 2.Enter food item name: hot dog Enter item price: 2 Enter item quantity: 5 RECEIPT 5 hot dog @ $ 2.0 = $ 10.0 Total cost: $ 10.0 Enter second food item name: ice cream Enter item price: 2.50 Enter item quantity: 4 RECEIPT 5 hot...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT