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]
4 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]4 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
If an online shopping site is experiencing a DDoS attack, what could be a possible impact of the attack?
lidiya [134]

D. A DDoS knocks a webpage offline by spamming the IP with loads of traffic so it over loads the server.

7 0
4 years ago
This is A C++ PROGRAM BTW!! Define a class named Money that stores a monetary amount. The class should have two private integer
inessss [21]
Jasminee accoo i'm very disappointed in you, this was a assignment that you were to do. Can you explain yourself?
7 0
4 years ago
Natural language generation is focused on?
Mila [183]

While natural language understanding focuses on computer reading comprehension, natural language generation enables computers to write. NLG is the process of producing a human language text response based on some data input. This text can also be converted into a speech format through text-to-speech services.

<em>-</em><em> </em><em>BRAINLIEST</em><em> answerer</em>

6 0
3 years ago
How to unblock your Wi-fi if it is blocked by your administrator .
alexgriva [62]

Answer:

you dont

Explanation:

you ask the admin to unblock it. if you dont know who did it, you had your ip grabbed and you cant do anything but call the police.

3 0
3 years ago
Is a three-prong grounding plug with the third pong broken-off safe to use.
ad-work [718]
What is the answer choices dude
8 0
3 years ago
Other questions:
  • Two positive outcomes generally associated with modern computing are greater _____.
    12·2 answers
  • Which option allows you to view slides on the full computer screen?
    11·1 answer
  • How to show neither precious nor accurate
    13·1 answer
  • Which steps can you use to open the Reveal Formatting pane?
    5·2 answers
  • Cell references in a formula are called _____.<br> a. assumptionsc. numbersb. valuesd. content
    11·1 answer
  • Explain how a monitor can display the letters that you type on a keyboard. (Hint: Three Basic Computer Functions) *
    11·1 answer
  • "What router feature provides basic security by mapping internal private IP addresses to public external IP addresses, essential
    10·1 answer
  • Find true or false. A hacker is hacking software with access in sensitive information from your computer​
    9·1 answer
  • Free coins who is octane and dont say u dont know because i will do the same to u
    13·2 answers
  • PLEASE HELP ASAP
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!