Exercise 3 --- "Calculator"

 Exercise 3 --- 

"Calculator"

Q: Design a calculator which will correctly solve all the problems:

Solution:
# Exercise 3 - Calculator

"""Design a calculator which will correctly solve all the problems:"""

# Solution :

# Input Part
Calculator_On = True
print('Welcome, Your Calculator is ready to serve you !')
while (Calculator_On == True):
x = int(input('Please enter First number :\n'))
y = int(input('Please enter Second number : \n'))
operator = input('Please Select Operator from these {*,/,+,-} : ')

# Output Part
if (operator == '*'):
print('Output : ', x * y)
elif (operator == '/'):
print('Output : ', x / y)
elif (operator == '+'):
print('Output : ', x + y)
elif (operator == '-'):
print('Output : ', x - y)

print(' Do you want to calculate again?', '\n', 'Please type 1 for YES or 0 for NO.')
Calculator_On = int(input())
if (Calculator_On == False):
print('Thank you, Hope you will use me again !')

Comments

Popular posts from this blog

Python Tutorial 38 --- "Self & __init__() (Constructors)(OOPS 3)"

Python Exercise 7 --- "Snake, Water, Gun"

Python Tutorial 24 --- "Using Python External & Built In Modules"