Welcome to Westonci.ca, the Q&A platform where your questions are met with detailed answers from experienced experts. Discover detailed solutions to your questions from a wide network of experts on our comprehensive Q&A platform. 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 //
Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Thank you for visiting Westonci.ca, your go-to source for reliable answers. Come back soon for more expert insights.