Question

In: Computer Science

Make a python calculator which deals with arithmetic include plus, minus, divide, and multiply as well...

Make a python calculator which deals with arithmetic include plus, minus, divide, and multiply as well as explaining each answer and use if statement using sign operator.

Solutions

Expert Solution

Implemented the code as per the requirement. As python is indentation specific, you may not get the formatted text while copying the code,
so I'm attaching the screenshots of the code for reference. Please make sure when you are executing the below code you have same format, especially tabs.

Please comment if any modification required or if you need any help.

code:

====

inp = input("Enter the expression: ")
if(inp.__contains__("+")):
    left = int(inp.split("+")[0].strip())
    right = int(inp.split("+")[1].strip())
    print("Addition of ",left," and ",right," is",(left+right))
elif(inp.__contains__("-")):
    left = int(inp.split("-")[0].strip())
    right = int(inp.split("-")[1].strip())
    print("Subtraction of ",left," from ",right," is",(left-right))
elif(inp.__contains__("*")):
    left = int(inp.split("*")[0].strip())
    right = int(inp.split("*")[1].strip())
    print("Multiplication of ",left," and ",right," is",(left*right))
elif(inp.__contains__("/")):
    left = int(inp.split("/")[0].strip())
    right = int(inp.split("/")[1].strip())
    print("Division of ",left," and ",right," is",(left/right))
else:
    print("Invalid input!!!")

code screenshot:

=============

Output:

======


Related Solutions

PYTHON: Im writing a program to make a simple calculator that can add, subtract, multiply, divide...
PYTHON: Im writing a program to make a simple calculator that can add, subtract, multiply, divide using functions. It needs to ask for the two numbers from the user and will ask the user for their choice of arithmetic operation 1- subtract 2- add 3- divide 4- multiply
Must make a "Calculator" using C. The calculator must subtract, add, divide, and multiply inputs, and...
Must make a "Calculator" using C. The calculator must subtract, add, divide, and multiply inputs, and tell whether a number is prime or not. The user chooses how many inputs go into the calculator. For example, the code will ask the user what function they want. If the user chooses to subtract, the the code will then ask the user how many numbers they want to subtract. After, the code will ask the user to input as many numbers as...
Using Java Write a simple calculator which can add, subtract, multiply, and divide. Here are the...
Using Java Write a simple calculator which can add, subtract, multiply, and divide. Here are the specifications for the calculator: The calculator has one “accumulator”, which holds the result of all prior calculations. The calculator is set to 0.0 when the calculator is turned on (i.e., instantiated). On the console, the user then enters an operator (+, -, *, or /) and a number. Your console will then apply the operator and operand to the number in the accumulator, and...
Calculator Class Instructions Create a calculator class that will add, subtract, multiply, and divide two numbers....
Calculator Class Instructions Create a calculator class that will add, subtract, multiply, and divide two numbers. It will have a method that will accept three arguments consisting of a string and two numbers example ("+", 4, 5) where the string is the operator and the numbers are what will be used in the calculation. The class must check for a correct operator (+,*,-,/), and a number (integer) for the second and third argument entered. The calculator cannot divide by zero...
Write a Python program to add, multiply and divide any two numbers.
Write a Python program to add, multiply and divide any two numbers.
Write a calculator program that prompts the user with the following menu: Add Subtract Multiply Divide...
Write a calculator program that prompts the user with the following menu: Add Subtract Multiply Divide Power Root Modulus Upon receiving the user's selection, prompt the user for two numeric values and print the corresponding solution based on the user's menu selection. Ask the user if they would like to use the calculator again. If yes, display the calculator menu. otherwise exit the program. EXAMPLE PROGRAM EXECUTION: Add Subtract Multiply Divide Power Root Modulus Please enter the number of the...
Implement a Java program that is capable of performingthe basic arithmetic operations (add, subtract, multiply, divide)...
Implement a Java program that is capable of performingthe basic arithmetic operations (add, subtract, multiply, divide) on binary numbers using only logical operations (i.e., not using the actual mathematical operators thatJava already supports).A skeleton for the implementation is provided and can be downloaded from Canvas.In this source file  (BinaryCalculator.java), there is already code to read stringsfrom the keyboard.  The program will exit if the string “QUIT” is received, otherwiseit will attempt to process commands of the form: <binary operand 1> <operator> <binary...
Write a Python script that will be used as a calculator to allow simple arithmetic computation...
Write a Python script that will be used as a calculator to allow simple arithmetic computation of two input integer numbers. Requirements: a. The script should first allow the user to select if they want to add, subtract, multiply or divide two integer digits. b. The script should pass the user inputs to a function using arguments for computation and the results return to the main part of the script. c. The return value will be tested to determine if...
Make a calculator in python that always gives an explanation when the answer is output. It...
Make a calculator in python that always gives an explanation when the answer is output. It must be detailed
Use Python 3, please type. Write a Python 3 program which is an arithmetic quiz for...
Use Python 3, please type. Write a Python 3 program which is an arithmetic quiz for children. The program asks the user to calculate the multiplication of two numbers generated at random in your code. The numbers should be in the range 1 through 10. User input is shown in bold black font in the example below. You will need to use random numbers. You should type the recommended comments at the top of your code and include three test...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT