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
Stolb23 [73]
3 years ago
6

Write a program that prompts the user to enter an equation in the form of 10 5, or 10-5, or 1*5, or 13/4, or 13%4. The program s

hould then output the equation, followed by an equal sign, and followed by the answer.
Computers and Technology
1 answer:
grandymaker [24]3 years ago
5 0

Answer:

  1. equation = input("Enter an equation: ")
  2. if("+" in equation):
  3.    operands = equation.split("+")
  4.    result = int(operands [0]) + int(operands[1])
  5.    print(operands[0] + "+" + operands[1] + "=" + str(result))
  6. elif("-" in equation):
  7.    operands = equation.split("-")
  8.    result= int(operands [0]) - int(operands[1])
  9.    print(operands[0] + "-" + operands[1] + "=" + str(result))  
  10. elif("*" in equation):
  11.    operands = equation.split("*")
  12.    result = int(operands [0]) * int(operands[1])
  13.    print(operands[0] + "*" + operands[1] + "=" + str(result))  
  14. elif("/" in equation):
  15.    operands = equation.split("/")
  16.    result = int(operands [0]) / int(operands[1])
  17.    print(operands[0] + "/" + operands[1] + "=" + str(result))  
  18. elif("%" in equation):
  19.    operands = equation.split("%")
  20.    result = int(operands [0]) % int(operands[1])
  21.    print(operands[0] + "%" + operands[1] + "=" + str(result))

Explanation:

The solution code is written in Python 3.

Firstly prompt user to enter an equation using input function (Line 1).

Create if-else if statements to check if operator "+", "-", "*", "/" and "%" exist in the input equation. If "+" is found (Line 3), use split method to get the individual operands from the equation by using "+" as separator (Line 5). Output the equation as required by the question using string concatenation method (Line 6).  The similar process is repeated for the rest of else if blocks (Line 7 - 22).  

You might be interested in
Over the past week, every time Larry has started his computer, he has noticed that the time is not correct. Larry didn't conside
DiKsa [7]

Answer + Explanation:

You can tell Larry to set his device's location on 'enabled' at all times. That way, you get the time zone too. For example. if you live in the US, and your Location is not enabled, then the device may think that you are in China, or where the device was last at.

4 0
2 years ago
Software refers to:
aev [14]

Answer:

Software refers to the programs that run on your computer.

Explanation:

Examples are Word and PowerPoint. Computer programs contain instructions that the hardware carries out. ... Another program (called a compiler or interpreter) translates these instructions into machine language which the computer hardware understands.

7 0
2 years ago
Read 2 more answers
Which of the following is something that an Information Technology (IT) professional would do?
Reptile [31]

Answer:

Probably the last one, build and repair computers.

6 0
2 years ago
List three options for printing a presentation.
Andrew [12]

Answer:

 There are many different types of options we can use to print our presentation slides are as follows:

  • We can print the entire slide of the presentation and it is provide the whole detail of our presentation together.
  • We can also printing the selected parts in the slides that is necessary and important for us and save as short notes.
  • We can print various types of presentation handouts for the distribution purpose to the audience.
4 0
3 years ago
What is<br> a an<br> output device
wel

Answer:

<em>Any</em><em> </em><em>pie</em><em>ce</em><em> </em><em>of</em><em> </em><em>comp</em><em>uter</em><em> </em><em>hard</em><em>ware</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em><em>.</em>

6 0
2 years ago
Other questions:
  • One way to make a data table stand out on the screen and help bring the viewer’s attention to it is to add a shadow behind the t
    12·2 answers
  • In a PERT network, non-critical activities that have little slack need to be monitored closely
    14·1 answer
  • How many frequencies does a full-duplex qam-64 modem use?
    8·2 answers
  • What is your perception of what a safe classroom looks like
    15·1 answer
  • Why OSI is called open system?
    8·1 answer
  • The following code processes a file containing five positive numbers. What will the variable $result contain after the code is e
    13·1 answer
  • Which type of cables are used for high-capacity trunk lines that provide main routes for telephone, cable, and internet communic
    15·1 answer
  • If you often purchase items at the same e-tailer and do not have to type in your username and/or password, this probably means
    13·1 answer
  • MULTI SELECTION
    9·1 answer
  • Firestick optimizing system storage and applications
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!