1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Tju [1.3M]
3 years ago
10

Ill give 100 points to whoever gives me the CORRECT answer. I keep getting syntax errors when I do the "add:" part. Can someone

walk me through this code?
Part A One of the biggest benefits of writing code inside functions is that we can reuse the code. We simply call it whenever we need it! Let’s take a look at a calculator program that could be rewritten in a more reusable way with functions. Notice that two floats (decimal numbers, but they can also include integers) are inputted by the user, as an operation that the user would like to do. A series of if statements are used to determine what operation the user has chosen, and then, the answer is printed inside a formatted print statement. 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.") Your job is to rewrite the program using functions. We have already looked at a function that adds two numbers. Using that as a starting point, we could call the add function from within our program in this way: if operation == “add”: result = add(num1, num2) print(num1, "+", num2,"=",result) Now it’s your turn to do the following: Type all of the original code into a new file in REPL.it. Copy the add function from the unit and paste it at the top of your program. 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. Rewrite the main code so that your functions are called. Part B There are many different ways that a user could tell us that he or she would like to add two numbers in our calculator program. The user could type “add”, “Add”, “ADD”, or “+”, to name a few possibilities. Of cour
Computers and Technology
2 answers:
sertanlavr [38]3 years ago
7 0

working on rewriting my code so i can paste it here! itll be done in a sec

Olin [163]3 years ago
6 0

Answer:

sorry but there is not enough information to complete this

Explanation:

You might be interested in
What is an implicit benefit to Monetary Policy?
Mariana [72]
The answer to your question is a
6 0
3 years ago
How do you set up nordvpn with spectrum?
Setler [38]

Answer:

simple

Explanation:

use nordvpn with discount code: Chonchode

7 0
3 years ago
Is windows 7 professional faster than home premium?
Olin [163]
Widows 7 is no longer supported for anti virus, I recommend a windows 10 license
8 0
3 years ago
A computer connected to the internet that asks for data is a ________. aggregator surrogate server client
Tems11 [23]
The answer to this question would be client.

Client is the computer that most people use. When you browsing a web using the internet, your computer will ask for data from the web server and the data will be arranged into graphical picture or words what you see on your monitor. Server is the computer that gives data the client ask for.
3 0
3 years ago
Which of the following would a typical e-commerce website not include?
Vanyuwa [196]
They wouldn't include Employee Salaries
6 0
3 years ago
Other questions:
  • I need to write a program that accepts eight int values representing student test scores from the user and then displays each of
    14·1 answer
  • Which of the following correctly orders the investments from LOWER risk to HIGHER risk?
    7·2 answers
  • Suppose the file is sent continuously as one big message. how long does it take to send the file, assuming it is sent continuous
    15·1 answer
  • Choose the correct answer base on the Components of Computer System
    14·1 answer
  • How to do this PLEASE HELP 80 points!
    15·1 answer
  • What concept or principle requires layered, complementary controls sufficient to detect and deter infiltration and exploitation
    6·1 answer
  • Instead of sending an entire file in one big chunk across the​ Internet, __________ is used which dices the file up into little
    12·1 answer
  • Complete the statement using the correct term.
    6·1 answer
  • Write a method doubleUp that doubles the size of a list of integers by doubling-up each element in the list. Assume there's enou
    13·1 answer
  • Which of the following is NOT AN EXAMPLE of personal identifying
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!