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
Fwee Pwoints Fwor You! :3
Fittoniya [83]

Answer:

Hey thanks for them........

8 0
3 years ago
Read 2 more answers
Ano ang bunga ng pagsunod sa tamang konsiyensiya?
gladu [14]

Answer:

A.

Explanation:

mapalaganap ang kabutihan

8 0
3 years ago
Read 2 more answers
While microsoft excel can be an efficient tool for developing a dss, compared to using a programming language like c++, a shortc
klasskru [66]
Although Microsoft Excel isn't a language itself, nor does it come with its own built-in language, I do see what you mean regarding its ability to create functions and whatnot to make the spreadsheet more versatile and efficient.

Yeah, syntactical errors (or compile errors in a compiled language like C++), are going to be harder to spot in Excel than it would be in a programming language, surprisingly. This is because of the reason that I just said; most programming languages such as C++ are compiled languages, meaning that they are written in an IDE (such as Visual Studio, for C++), which is used for writing out, debugging, and compiling programs in to a executable format. The IDE would not let the compilation process finish successfully unless there were no syntax errors in the code itself (not to be confused with runtime errors; those are the harder ones to iron out, as the compiler will not tell you there is an error).
3 0
4 years ago
Big Bob's Construction has many construction sites where computers are located. At the remote sites, Internet connectivity can b
Sergio039 [100]

Answer:

WAN or wide area network using satellite

Explanation:

A WAN or wide area network is a network of local area networks that could span beyond a geographical region.

For a network administrator to manage the remote construction site, a stable network connection should be established using a wireless medium like a satellite to connect the site's network to the office network.

8 0
3 years ago
Does learning swift is hard? more than android?
ladessa [460]
No it is not. it's quite simple when you get the hang of it
4 0
4 years ago
Other questions:
  • You bought a monochrome laser printer two years ago. The printer has gradually stopped feeding paper. Which printer component sh
    14·1 answer
  • When a field is declared static there will be ________. Group of answer choices two reference copies of the field for each metho
    14·1 answer
  • Invalid length parameter passed to the LEFT or SUBSTRING function (below)".
    6·1 answer
  • What are some types of vehicle technology advancements?
    5·1 answer
  • Give two advantages of representing integers in pure binary.
    5·1 answer
  • What is the primary means by which attackers infect computers with these attacks? How do these attacks commonly occur?
    8·1 answer
  • 10 points giveaway!!!!!!!!!!!!!!!!
    6·2 answers
  • Does anybody know how to fix my Minecraft??? My character isn’t loading and realms aren’t working?? Look at the picture!
    5·1 answer
  • In cell J6, insert a formula using the OR function that returns TRUE if the rating (cell 16) equals "A" or the email reminder (c
    5·1 answer
  • We're given the training set data with the following values for variable X1:
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!