197k views
2 votes
NEED THIS ASAP!!!

Write a program to calculate the 4 basic arithmetic functions. Given two numeric inputs and an operation, have the program utilize an algorithm that will complete the function. Utilize if, else-if, and else statements efficiently for maximum credit.

good answers only please

User WhoIsDT
by
3.9k points

1 Answer

4 votes

number1 = float(input("Enter a number: "))

number2 = float(input("Enter a number: "))

operator = input("Enter the operator: ")

if operator == "+":

print("{} + {} = {}".format(number1, number2, (number1 + number2)))

elif operator == "-":

print("{} - {} = {}".format(number1, number2, (number1 - number2)))

elif operator == "*":

print("{} * {} = {}".format(number1, number2, (number1 * number2)))

else:

print("{} / {} = {}".format(number1, number2, (number1 / number2)))

I wrote my code in python 3. I hope this helps!

User Cristianorbs
by
4.2k points