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

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 20:20
Sometimes writers elaborate on the truth when recalling past events so they can enhance their narrative essay with more interesting descriptions. do you feel that published writers should or should not embellish real life events just to make their stories more interesting?
Answers: 2
question
Computers and Technology, 22.06.2019 02:30
Write a program that takes in 3 inputs [players (int type), expected game time (double type), team (char type)] and calculates actual game time (double) based on the following conditions: if the number of players or the expected game time is less than or equal to zero, it should output wrong input if the number of players is greater than 0 and less than or equal to 6 and if they are on the â€r’ or â€r’ team, their game time will be 10% faster. and if they are on the â€b’ or â€b’ team, their game time will be 15% faster. and if they are on the â€y’ or â€y’ team, their game time will be 20% faster. and if they are on any other team, they will play 0% faster. if the number of players is greater than 6 but less than or equal to 12 and if they are on the â€r’ or â€r’ team, their game time will be 20% faster. and if they are on the â€b’ or â€b’ team, their game time will be 25% faster. and if they are on the â€y’ or â€y’ team their game time will be 30% faster. and if they are on any other team, they will play 0% faster. if the number of players is greater than 12 but less than or equal to 18 and if they are on the â€r’ or â€r’ team, their game time will be 30% faster. and if they are on the â€b’ or â€b’ team, their game time will be 35% faster. and if they are on the â€y’ or â€y’ team, their game time will
Answers: 2
question
Computers and Technology, 22.06.2019 17:00
Annie is creating a corporate report for a company’s annual meeting. in the report, she wants to add the signature of various department heads. which device can annie use to capture signatures to include in the report? a. printer b. monitor c. e-reader d. digitizing tablet
Answers: 1
question
Computers and Technology, 22.06.2019 21:30
How do you take a green screen out of the video while editing?
Answers: 2
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
question
Mathematics, 12.09.2019 00:30
question
Mathematics, 12.09.2019 00:30
question
Mathematics, 12.09.2019 00:30
question
Mathematics, 12.09.2019 00:30
question
Mathematics, 12.09.2019 00:30
Questions on the website: 13722360