#1 Python Beginner Project|How to build a calculator in 3 steps|
Python Project - Build a simple calculator
How to build a calculator using python?
answer: `
Source Code:
def add(no1, no2):
return no1+no2
def subtract(no1, no2):
return no1 - no2
def multiply(no1, no2):
return no1 * no2
def divide(no1, no2):
return no1/no2
first_num = int(input("First number: "))
operator = input("(+)or(-)or(*)or(/)")
second_num = int(input("Second number: "))
if operator == '+':
answer = add(first_num, second_num)
elif operator == "-":
answer = subtract(first_num, second_num)
elif operator == '*':
answer = multiply(first_num, second_num)
elif operator == '/':
answer = divide(first_num, second_num)
print(f"Answer = {answer}")
Comments
Post a Comment