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, 22.06.2019 10:30
How can a user open a blank presentation? 1.on the file menu, click new, and then click recent templates 2.on the file menu, click new, and then click blank presentation 3. on the view menu, click templates, and then click recent templates 4. on the view menu, click samples, and then click blank presentation
Answers: 1
question
Computers and Technology, 23.06.2019 09:10
(328 inc. 448 ind. 480 in25. john has a collection of toy cars. he has 2 red cars, 4 blue cars, 4 black cars, and 6 yellowcars. what is the ratio of red cars to yellow cars? a. 1: 2b. 1: 3c. 1: 626. the net of a right triangular prism is shown below.
Answers: 2
question
Computers and Technology, 23.06.2019 21:40
Simon says is a memory game where "simon" outputs a sequence of 10 characters (r, g, b, y) and the user must repeat the sequence. create a for loop that compares the two strings. for each match, add one point to user_score. upon a mismatch, end the game. sample output with inputs: 'rrgbryybgy' 'rrgbbrybgy'
Answers: 3
question
Computers and Technology, 24.06.2019 07:00
Selective is defined as paying attention to messages that are consistent with one’s attitudes and beliefs and ignoring messages that are inconsistent.
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
question
Mathematics, 18.03.2021 17:40
Questions on the website: 13722363