Hello Everyone.
In this blog you are going to see how to create a command line calculator using python 3 .
This is the code you can copy -
:
#calculator which will continue calculating when you won't stop
while True:
user = input("Do You Want To Continue Calculation? \n Press y for continue and n for cancel.\n")
if user == 'n':
print("Sorry For Inconvenience.....")
break
elif user == 'y':
print("Calculator Is On")
print("Which Operation You want?\n + = Addition\n - = Substraction \n * = Multiplication \n / = Divide\n")
user_c = input()
first_nu = int(input("Enter The First Number:\n"))
second_nu = int(input("Enter The Second Number:\n"))
add = (first_nu + second_nu)
sub = (first_nu - second_nu)
multiple = (first_nu * second_nu)
div = (first_nu / second_nu)
if user_c == '+':
print(f"The Sum Of two Numbers is. \n{add} ")
if user_c == '-':
print(f"The Difference Between Two Numbers is \n {sub}")
if user_c == '*':
print(f"The Multiple Of The Two Numbers is\n {multiple}")
if user_c == '/':
print(f"The Division Of The Two Numbers is \n {div}")
::::
Comments
Post a Comment