subject
Computers and Technology, 02.04.2020 07:27 860jay

1. Type all of the original code into a new file in REPL. it. 2. Copy the add function from the unit and paste it at the top of your program. 3. Write 3 additional functions: subtract, multiply, and divide. Pay careful attention to the parameters and return statement. Remember to put the three functions at the top of your Python program before your main code. 4. Rewrite the main code so that your functions are called.

that “add” is the same as “Add”.
We can use a list to make our program a bit more robust. We can also use the IN operator to check for certain values in that list. Take a look at this if statement’s opening line:
if operation in [“add”, “Add”, “ADD”, “+”]:
1. Make those changes in your program and verify that it works.
2. Consider all of the possible words the user might enter to subtract, multiply, or divide.
3. Rewrite the first lines of each of your if statements to use lists.
4. Thoroughly test your new program, trying out each of the four operations.
5. Share the link to your Python code in REPL. it with your teacher by clicking on the share button and copying the link.

The code is

num1 = float(input("Enter your first number: "))
num2 = float(input("Enter your second number: "))
operation = input("What operation would you like to do? Type add, subtract, multiply, or divide.")
if operation == "add":
print(num1, "+", num2,"=", num1 + num2)
elif operation == "subtract":
print(num1, "-", num2,"=", num1 - num2)
elif operation == "multiply":
print(num1, "*", num2,"=", num1 * num2)
elif operation == "divide":
print(num1, "/", num2,"=", num1 / num2)
else:
print("Not a valid operation.")

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:00, lexhorton2002
The great length of north america causes the climate to be varied. true false
Answers: 2
image
Computers and Technology, 22.06.2019 18:30, yeeet26
If an improvement creates no significant change in a product’s performance, then it is a(n) ? a0 design improvement. (there are no answer choices)
Answers: 1
image
Computers and Technology, 23.06.2019 15:30, Dweath50
The processing of data in a computer involves the interplay between its various hardware components.
Answers: 1
image
Computers and Technology, 24.06.2019 04:30, minecrafter3882
Fall protection, confined space entry procedures, controlled noise levels, and protection from chemical hazards are some of the things that contribute to a safe what
Answers: 1
You know the right answer?
1. Type all of the original code into a new file in REPL. it. 2. Copy the add function from the unit...

Questions in other subjects: