Welcome to Westonci.ca, where you can find answers to all your questions from a community of experienced professionals. Our platform offers a seamless experience for finding reliable answers from a network of experienced professionals. Join our platform to connect with experts ready to provide precise answers to your questions in different areas.
Sagot :
I am sure you are using an editor but if doesn’t work you can search online python compiler .
Answer :
We know that a calculater should be able to calculate ( addition , subs traction, multiplication, division …etc)
# first takng inputs
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
# operations
print("Operation: +, -, *, /")
select = input("Select operations: ")
# check operations and display result
# add(+) two numbers
if select == "+":
print(num1, "+", num2, "=", num1+num2)
# subtract(-) two numbers
elif select == "-":
print(num1, "-", num2, "=", num1-num2)
# multiplies(*) two numbers
elif select == "*":
print(num1, "*", num2, "=", num1*num2)
# divides(/) two numbers
elif select == "/":
print(num1, "/", num2, "=", num1/num2)
else:
print("Invalid input")
Answer :
We know that a calculater should be able to calculate ( addition , subs traction, multiplication, division …etc)
# first takng inputs
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
# operations
print("Operation: +, -, *, /")
select = input("Select operations: ")
# check operations and display result
# add(+) two numbers
if select == "+":
print(num1, "+", num2, "=", num1+num2)
# subtract(-) two numbers
elif select == "-":
print(num1, "-", num2, "=", num1-num2)
# multiplies(*) two numbers
elif select == "*":
print(num1, "*", num2, "=", num1*num2)
# divides(/) two numbers
elif select == "/":
print(num1, "/", num2, "=", num1/num2)
else:
print("Invalid input")
Answer:
numb1 = int(input('Enter a number one: '))
Operation = input('Enter operation: ')
numb2 = int(input('Enter a number two: '))
def Calculator(numb1, Operation, numb2):
if Operation == '+':
print(numb1+numb2)
elif Operation == '-':
print(numb1-numb2)
elif Operation == '×':
print(numb1*numb2)
elif Operation == '÷':
print(numb1/numb2)
elif Operation == '^':
print(numb1**numb2)
elif Operation == '//':
print(numb1//numb2)
elif Operation == '%':
print(numb1%numb2)
else:
print('Un supported operation')
Calculator(numb1, Operation, numb2)
Explan ation:
Write a Python Calculator function that takes two numbers and the operation and returns the result.
Operation Operator
Addition +
Subtraction -
Multiplication *
Division /
Power **
Remainder %
Divide as an integer //
Thank you for your visit. We are dedicated to helping you find the information you need, whenever you need it. We appreciate your visit. Our platform is always here to offer accurate and reliable answers. Return anytime. Thank you for trusting Westonci.ca. Don't forget to revisit us for more accurate and insightful answers.