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, 23.06.2019 00:30
Which one of the following is the most accurate definition of technology? a electronic tools that improve functionality b electronic tools that provide entertainment or practical value c any type of tool that serves a practical function d any type of tool that enhances communication
Answers: 1
question
Computers and Technology, 23.06.2019 06:40
How many nibbles can be stored in a 16-bit word?
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
Select the correct answer. peter has launched a website that features baby products. however, clients often find they are unable to access the website because the server is down. which feature of cybersecurity should peter focus on for his website? a. data authenticity b. data privacy c. data availability d. data integrity e. data encryption
Answers: 3
question
Computers and Technology, 23.06.2019 19:30
You can apply several different worksheet themes from which tab?
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
Chemistry, 04.08.2019 23:30
question
Mathematics, 04.08.2019 23:30
Questions on the website: 13722359