Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Calculator in Python
- # --------------------
- # -*-coding:UTF-8 -*
- import os
- # Introduction
- print ("Calclulator in Python\n")
- print ("Available :\n")
- print ("+\n-\n/\n*\n**\n%\n")
- result = 0
- stop = False
- choice = ""
- # Main Loop
- while stop == False:
- # Take Input
- # First Number
- while True:
- first_number = input("Enter First Number : ")
- if first_number.isdigit():
- first_number = float(first_number)
- break
- # Operation
- operation = input("Operation ? ")
- # Second Number
- while True:
- second_number = input("Enter Second Number : ")
- if second_number.isdigit():
- second_number = float(second_number)
- break
- # Calculation
- if operation == "+":
- result = first_number + second_number
- elif operation == "-":
- result = first_number - second_number
- elif operation == "*":
- result = first_number * second_number
- elif operation == "/":
- result = first_number / second_number
- elif operation == "**":
- result = first_number ** second_number
- elif operation == "%":
- result = first_number % second_number
- else:
- print ("That's not an operation !")
- # Result
- print (first_number," ",operation," ",second_number," equals: ",result,".")
- # Asking for ReCalculation
- choice = input("Do you want to start over ?(O/N): ")
- if choice == "O":
- continue
- else:
- stop = True
- os.system("pause")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement