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
What is the best wi-fi name you have ever seen?
elena-s [515]

Answer:

bill wi the science fi

Explanation:

8 0
2 years ago
Human systems integration (hsi), a supportability issue that every program should consider, addresses such factors as accessibil
Tju [1.3M]

I guess the word in the blank is Standardization.

Human systems integration (HSI), a supportability issue that every program should consider, addresses such factors as accessibility, visibility, testability, and Standardization.


6 0
2 years ago
Which of the following blocks is least similar to the others?
GuDViN [60]
The answer is A or B
4 0
3 years ago
Read 2 more answers
Digital subscriber lines: are very-high-speed data lines typically leased from long-distance telephone companies. are assigned t
V125BC [204]

Answer: Operate over existing telephone lines to carry voice, data, and video.

Explanation:

Digital subscriber line is a means of transferring high bandwidth data over a telephone line. Such data could be a voice call, graphics or video conferencing. DSL uses a user's existing land lines in a subscriber's home, allowing users to talk on a telephone line while also being connected to the Internet. In most cases, the DSL speed is a function of the distance between a user and a central station. The closer the station, the better its connectivity.

5 0
3 years ago
On a printed circuit board, electronic components will be mounted from the
Likurg_2 [28]
On a printed circuit board, electronic parts will be mounted from the substrate side of the board. The leads jab through the substrate and the copper sheeting that has been carved. The leads are then soldered to the copper.

I hope the answer will help you. 
3 0
3 years ago
Other questions:
  • An information system is the entire set of __________, people, procedures, and networks that enable the use of information resou
    8·1 answer
  • A ____ client locates all or most of the processing logic on the server.
    11·1 answer
  • True/False
    15·1 answer
  • Which of the following “invisible” marks represents an inserted tab?
    11·2 answers
  • If your pulse is higher than your Target Heart Rate during exercise, what should you do?
    5·2 answers
  • How do operating system work?
    5·1 answer
  • What part of the meat help you identify the less tender cuts​
    13·1 answer
  • what will allow you to immediately exit the program without rebooting the computer, when you realize your browser is not respond
    7·1 answer
  • A keyboard would be considered _____. Select 2 options.
    13·2 answers
  • Margie has found a stock template to use. She changes a few things about the formatting and then saves the
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!