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]
2 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]2 years ago
7 0

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

Olin [163]2 years ago
6 0

Answer:

sorry but there is not enough information to complete this

Explanation:

You might be interested in
what type of clause must you always use with DEKETE or UPDATE to avoid inadvertently changing data elsewhere in the database​
Shkiper50 [21]

While you’re using the DELETE or UPDATE to change the data in any database like MySQL or ORACLE, the WHERE clause can be used to avoid inadvertently changing data everywhere.

<u>Explanation:</u>

The WHERE clause checks the condition and the changes mentioned by the DELETE or UPDATE command will be done if the condition is true. There are also other clauses like HAVING, IN which will have range either inclusive or exclusive.

It is also noted that in MySQL, there is a method called WorkBench which enables safe mode and doesn’t execute statements without the WHERE clause.

5 0
2 years ago
Calvin needs to design a simple yet professional interface for his users. Which option should he implement?
r-ruslan [8.4K]

Answer:

switchboard

Explanation:

The option that he should implement would be a switchboard interface design. These design structures for graphic user interfaces use a single main page, large icons/buttons, a fixed navigation menu, and all the necessary functionality right in front of the user. This design is made with simplicity in mind in order to make it as easy as possible for a new user to pick up and efficiently and intuitively navigate the user interface. Therefore, since Calvin needs a simple yet professional design, this would be the best implementation.

7 0
2 years ago
Read 2 more answers
One of the ways to create a horizontal navigation menu from an unordered list is to a. set the display property of the element w
Gennadij [26K]

Answer: a. set the display property of the element within each li element to inline

Explanation: In an unordered list, <em>ul</em> signifies the list and <em>li</em> signifies the elements in the list. When you want to display the elements in a list in a horizontal form, for example if you need a horizontal menu, a quick way of doing this is setting the display of li to inline by writing it as follows in css:

<em>li { </em>

<em>Display: inline; </em>

<em>} </em>

This will order the elements in the list into the form of a horizontal menu .

8 0
3 years ago
What are the difference among the whole note, half note and quarter note ? (this is music)
igor_vitrenko [27]

Answer:

The second note in is called the half note and held for two counts  half a whole note. Notice it has a stem attached to it.The quarter note is the third note;it looks like a filled-in half note, with the same stem attached. You hold it for one full count, which is a quarter of a whole note.

Explanation:

7 0
2 years ago
Read 2 more answers
I'm not sure how to do these. By the way, it has to be python.
frutty [35]

Task 1:

float75 = float(75)

string75 = "75"

# you cannot add together a number and a string because a string has no inherent numerical value like a number does.

Task 2:

num = float(input("Enter a number"))

print(num**2)

Task 3:

num = int(input("Enter an integer: "))

print("When you divide "+str(num)+" by 7, the quotient is "+str(num//7)+" and the remainder is "+str(num%7)+".")

Task 4:

gigs = int(input("How many gigabytes does your flashdrive hold? "))

print("A flashdrive with "+str(gigs)+ " gigabyte(s) holds "+str(gigs*8589934592)+" bit(s).")

For task 4, you might have to change the number 8589934592 to something else. I'm not entirely sure how many bits are in a gigabyte. I hope this helps though.

6 0
2 years ago
Other questions:
  • Sum.Write a program that prompts the user to read two integers and displays their sum.Your program should prompt the user to rea
    11·1 answer
  • How would Microsoft Word inform you of the error in the sentence below? (Tip: The error is in bold.)
    7·1 answer
  • Hen using presentation software, what do you do when you "compose a slide"?
    5·1 answer
  • The box formed by the intersection of a row and column in a spreadsheet program is known as a ________.
    13·1 answer
  • Was the type writer the first part of the keyboard? ​
    8·1 answer
  • Which diagram is used as a popular technique for investigating causes and effects? 1. Cause and effect 2. Fishbone/lshikawa 3. R
    13·1 answer
  • Implement the function printTwoLargest that inputs an arbitrary number of positive numbers from the user. The input of numbers s
    14·1 answer
  • What game is this?????????????????????
    15·1 answer
  • Help PLEASE ILL MARK as brainlest
    11·1 answer
  • What is business agility
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!