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
In a relational database application, a(n) ________ key is used to link one table with another.
mr_godi [17]

In a relational database application, a <u>foreign key</u> is used to link one table with another.

<h3>What is a foreign key?</h3>

In database management system (DBMS), a foreign key can be defined as a column whose value provides a link between the data that are stored in a table or relational database.

This ultimately implies that, a <u>foreign key</u> is used to link one table with another in a relational database application.

Read more on keys here: brainly.com/question/8131854

#SPJ12

6 0
2 years ago
What is meant by concentration of a solution​
Bad White [126]

Answer:

The concentration of a solution means the amount of solute present in a given or specific amount of solution. (presented in percentage)

For example, the Normal Saline solution normally used for different scientific experiment or so. The saline water has 0.9% of salt (sodium chloride). This is the concentration of solution of salt.

5 0
3 years ago
Read 2 more answers
Using a conversation voice is part of:
MaRussiya [10]
Need more information
4 0
3 years ago
The CPU converts into information. The CPU is the mastermind of the computer, controlling everything that goes on through a seri
Harman [31]

Answer:

Mathematical sequences

Explanation:

Just did it

5 0
3 years ago
Read 2 more answers
This is used in a program to mark the beginning or ending of a statement, or separate items in a list:_____
hammer [34]

Answer:

B) Punctuation

Explanation:

Punctuation are greatly used in different programming languages for different purposes. In the Java, C++ and C# Programming languages for example, two popular punctuation marks are the comma (,) and semi-colon (;). The comma is used for separating elements of a list and arrays, while the semi-colon indicates end of an executable statement or line of code. Other popular punctuation marks used in programming are periods (dot), question marks, parenthesis angle brackets and braces each implementing a specific grammatical syntax in the language.

5 0
3 years ago
Other questions:
  • Which group on the sparkline tools design tab would you choose if you wanted to change the data source of the sparkline? (1 poin
    10·1 answer
  • Which one of the following is an example of hacktivism according to you and why?
    11·1 answer
  • An information- and communication-based electronic exchange environment mostly occupied by sophisticated computer and telecommun
    13·1 answer
  • Special effects are added using the _____.
    16·1 answer
  • 1. Caches are important to providing a high-performance memory hierarchy to processors. Below is a list of 32-bit memory address
    7·1 answer
  • Internet is for everyone but it wont be if its users cannot protect their privacy and the confidentiality of transactions conduc
    6·1 answer
  • Number Array Class
    5·1 answer
  • When evaluating platforms, what is the key factor in ensuring a platform addresses an organization's needs?
    8·1 answer
  • Which of the following statements should be avoided when developing a mission statement?
    13·1 answer
  • Disadvantages of a grain crusher
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!