'''
Assignment No: 6
To simulate simple calculator that performs basic tasks such as,
addition,
subtraction,
multiplication and division.
'''
def add(x, y): # function definition of addition
return x + y
def subtract(x, y): # function definition of subtraction
return x - y
def multiply(x, y): # function definition multiplication
return x * y
def divide(x, y): # function definition of divide
return x / y
def main():
while(1):
print("Select operation.")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")
# Take input from the user
choice = input("Enter choice(1/2/3/4):")
try:
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
except:
print("Enter numbers as integers")
continue
if choice == '1':
print(num1,"+",num2,"=", add(num1,num2))
elif choice == '2':
print(num1,"-",num2,"=", subtract(num1,num2))
elif choice == '3':
print(num1,"*",num2,"=", multiply(num1,num2))
elif choice == '4':
print(num1,"/",num2,"=", divide(num1,num2))
else:
print("Invalid input")
if __name__ == '__main__':
main()
Assignment No: 6
To simulate simple calculator that performs basic tasks such as,
addition,
subtraction,
multiplication and division.
'''
def add(x, y): # function definition of addition
return x + y
def subtract(x, y): # function definition of subtraction
return x - y
def multiply(x, y): # function definition multiplication
return x * y
def divide(x, y): # function definition of divide
return x / y
def main():
while(1):
print("Select operation.")
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")
# Take input from the user
choice = input("Enter choice(1/2/3/4):")
try:
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
except:
print("Enter numbers as integers")
continue
if choice == '1':
print(num1,"+",num2,"=", add(num1,num2))
elif choice == '2':
print(num1,"-",num2,"=", subtract(num1,num2))
elif choice == '3':
print(num1,"*",num2,"=", multiply(num1,num2))
elif choice == '4':
print(num1,"/",num2,"=", divide(num1,num2))
else:
print("Invalid input")
if __name__ == '__main__':
main()
Easy to understand.
ReplyDeleteEasy
ReplyDeleteEasy to learn
ReplyDeleteEasy to understand
ReplyDeleteEasy to understand
ReplyDeleteVery nice program and easy to understand
ReplyDeleteUseful in daily works
ReplyDeleteIt Help us in basic calculations.
ReplyDeleteEasy
ReplyDeleteGot it π
ReplyDeleteDoneπ
ReplyDeleteQuite easy practical
ReplyDeleteEasy to learn
ReplyDeleteUnderstandable
ReplyDeleteEasy
ReplyDeleteEasy to learn
ReplyDeleteEasy
ReplyDeleteVery easy to understand
ReplyDeleteNice coding
ReplyDeleteVery simple coding
ReplyDeleteI loved this programme because this programme is very easily runs and easy to understand..π✌️π€©π
ReplyDeleteThanks everyone for ur valuable comments for more update and improvements too
ReplyDeleteSir how to make a scientific calculator
ReplyDeleteπππ
ReplyDeleteππ
ReplyDeleteEasy to understand
ReplyDeleteEasy to learn
ReplyDeleteππ
ReplyDeleteEasy to understandπ
ReplyDeleteThanks sir to help and support us to make the program easy and run......
ReplyDeleteIt's very informative and easy program
ReplyDeleteInformative
ReplyDeleteUnderstandable
ReplyDeleteLittle bit hard
ReplyDeleteEasy to understand
ReplyDeleteEasy to understand
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteEasy to understand
ReplyDeleteBut it says at last interval the name is not defined
ReplyDeleteEasy to understand
ReplyDeleteEasy program
ReplyDeleteA good way to learn not only the basic aspects of Python but also compiling various operations under one code.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteEasy program
ReplyDeleteEasy program
ReplyDeleteππ
ReplyDeleteππ
ReplyDeleteIt help us in daily basic calculations .
ReplyDeleteEasy program
ReplyDeleteEasy
ReplyDeleteB 02 Ganesh Gaikwad
ReplyDeleteIt help us in daily basic calculations
B-13-Ghumare Sonali Sudam
ReplyDeleteEasy to help in daily basic calculation
Understand
ReplyDeleteVery nice sir understood
ReplyDeleteEasy to understand
ReplyDeleteB-19- shrutika holkar
ReplyDeleteEasily understand
B-29-pooja kedar
ReplyDeleteEasily understood
Very important in future
ReplyDeleteVery simple sirπ
ReplyDeleteBatch No =A1
ReplyDeleteRoll No= 09