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
How exactly do I answer questions?
pshichka [43]

Answer:

If you mean this website, click the add answer button on the question

Explanation:

8 0
2 years ago
Having one password for all accounts is an easy way to remember passwords, but it will expose you to what risk?
Gwar [14]
<span>Having one password for all accounts is an easy way to remember passwords, but it will expose you to the risk of losing all of your accounts. If a person hacks one of your accounts, then they will have access to everything you own. </span>
3 0
3 years ago
What are three limitations of computer?​
Lady bird [3.3K]

Answer:

Explanation:

Three limittaions of computer are:

It requires reqular power supply to operate .

It needs instructions to perform a task.

It cannot memorize and recall.

8 0
3 years ago
One difference between setters and getters is: a setter has one or more parameters; a getter has no parameters.
tangare [24]
Boiiiiiiiii.
This is not a question
7 0
4 years ago
A trench is a narrow excavation in which the depth is greater than the width and the width does not exceed 15 feet. A. False B.
Arturiano [62]
I think it is false
4 0
4 years ago
Read 2 more answers
Other questions:
  • What commands will reset a network interface in Linux?
    13·1 answer
  • You learned about microcomputer a personal computer designed for use by an individual. Perform online research find out the diff
    12·1 answer
  • [15 points] 3.2 Lesson Practice (holy marry mother of joseph)
    7·1 answer
  • Which of the following is not one of the five major areas to include in your notes organizer?
    15·2 answers
  • What happens when a filter is applied to a database?
    13·1 answer
  • ____ is the security guarantee that people who intercept messages cannot read them. A. Availability B. Encryption C. Confidentia
    9·1 answer
  • When you see ####### in a cell, you should​
    11·1 answer
  • How many bytes does a common processor require to represent an integer?
    7·1 answer
  • Take a minute to reflect on your thoughts and learning so far and discuss:
    13·1 answer
  • Revisa un manual o instructivo de las maquinas o aparatos tecnologicos que tengas en tu casa. Luego, trata de encontrar algunas
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!