Advertisement
Guest User

Calc

a guest
Aug 19th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. ##init var
  2. ##Calc by Anzo, it's shitty just training ty.
  3. inp=0
  4. ust=0
  5. a=1
  6. b=1
  7. opt=["sum","substraction","multiplication","division"]
  8. rst=[a+b,a-b,a*b,a/b]
  9. r2t=["+","-","x","/"]
  10. ##Importing os for cls
  11. import os
  12. def cls():
  13.     os.system('cls')
  14. cls()
  15. #OptionSelect
  16. while True:
  17.     cls()
  18.     print("What options do you choose/nPress Enter to select, type 'C' to confirm")
  19.     print(">>",opt[ust],"<<")
  20.     ##debug
  21.     print(ust)
  22.     inp=input("")
  23.     if inp=="C":break
  24.     elif inp!="":continue
  25.     if not ust>2:
  26.         ust=ust+1
  27.     else:ust=0
  28.     #Garbage code
  29.     #print("you chose "+str(opt[ust])+".")
  30.     #input("Press Enter to continue")
  31. ##Calc
  32. while True:
  33.     cls()
  34.     print("Input first number to calculate")
  35.     try:
  36.         a=int(input())
  37.     except ValueError:continue
  38.     break
  39. ##Calcstep2
  40. while True:
  41.     cls()
  42.     print("Input second number to calculate")
  43.     try:
  44.         b=int(input(str(a)+r2t[ust]))
  45.     except ValueError:continue
  46.     break
  47. #Result
  48. while True:
  49.     rst=[a+b,a-b,a*b,a/b]
  50.     cls()
  51.     print("the result of the "+str(opt[ust])+" is:")
  52.     print(str(a)+str(r2t[ust])+str(b)+"="+str(rst[ust]))
  53.     print("Press Enter to exit")
  54.     input()
  55.     break
  56. #Bye
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement