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 decimal value for the jump control?
Allushta [10]

Answer:

24

Explanation:

11000 is equivalent to 24 because if you look at a flippy do, the base is 2. so going from right-left, 2^0 is 1 for the first 0. second zero would be 2^1 which is 2. then the third zero is 4 (2^2). since they are zero’s, they are turned off, but the 1’s indicate that those bases are turned on. the first one going from right to left would then be 8 (2^3) and the last 1 going from right-left is 16 (2^4). so 16+8=24!

edit: didn’t mean to rate myself 1 star lol

4 0
2 years ago
Because its radio waves can pass through walls or desktops,
jeka57 [31]
Bluetooth i believe, not too sure however but its ur best bet
5 0
3 years ago
a particular variety of database that works by connecting tables to each other. It is the most popular form of database and the
NeTakaya

Answer:

Relational Database      

Explanation:

  • Relational Database is the type of database in which data is stored and presented in the form of tables and it is used to access, manipulate and manage data.
  • Table is also called a relation. It consists of rows and columns where rows represent a record of data and columns represent the attributes of the data.
  • Every table has a primary key which uniquely identifies a row in a table and a foreign key is used to establish relationships among tables.
  • In relational database domain is used to define specify the possible values that an attribute can have.
  • Constraints can also be applied to the values of the attributes in the table.
  • There are many advantages of a relational database.
  • It can organize and manage bulk of information.
  • It is easy to add or delete data in the relational database according to the change in requirements.
  • Relational database ensures the consistency and integrity of data when many users obtain the same database at same time by using concurrency control methods.
  • It ensures security by limiting access rights to the data.
  • It also eliminates data redundancy and dependency using normalization technique which ensures data integrity and accuracy.
3 0
3 years ago
Question:
Vlad1618 [11]

Answer:

The file type that uses equations instead of pixels are D.EPS or vector files

Explanation:

3 0
3 years ago
In which category would Jamal most likely find an
Phantasy [73]

Answer C.Education

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • Why do we need to send emails
    12·1 answer
  • In the Application, "The Effect of FDI on Rentals and Wages in Singapore," the annual growth rate in real rental rates for the 1
    5·1 answer
  • 4. An abstract data type is defined as _____.
    14·1 answer
  • Which statement is NOT CORRECT?
    11·1 answer
  • Please Help! <br> I need good Anime to watch!
    7·1 answer
  • Term of The surroundings and conditions of your workplace
    6·1 answer
  • Can i get any information on this website i'd like to know what its for ?
    11·1 answer
  • As we move up a energy pyrimad the amount of a energy avaliable to each level of consumers
    10·1 answer
  • True or False
    9·1 answer
  • To optimize the flow of data into and out of the cpu, the modern mcc provides at least _______________ of data every time the cp
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!