Guest User

Untitled

a guest
Jul 22nd, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. import time
  2. def help():
  3. print("To operate the program, simply type a number, hit enter, type one of the following operations: (*, /, x, +, -, ^)\n")
  4. print("These operations will allow you to calculate. For commands you can enter after receiving a result from an operation, you can now type 'commands' for a list of commands.")
  5. print("=========================================================")
  6. commands = {'help':'- displays help documentation to user.', 'exit':'-closes the program.'}
  7. def commands():
  8. for key, value in dict.commands():
  9. print(key, value)
  10. main()
  11.  
  12. def exit():
  13. print("Exiting...")
  14. time.sleep(3)
  15.  
  16. def numeral(x):
  17. print("Enter an operator or command:")
  18. second = str(input())
  19. if second == '*':
  20. print("Enter another number to be operated on:")
  21. third = input()
  22. if type(third) == int or float:
  23. third = float(third)
  24. x = float(x)
  25. x = x * third
  26. print(x)
  27. numeral(x)
  28. else:
  29. print("You did not enter a number. Taking you back to main menu.")
  30. time.sleep(5)
  31. main()
  32.  
  33.  
  34. #x is the newly entered data. y is the first numeral entered and will be saved between functions as navigation around. z will be the last operator entered.
  35. def main(x,y,z):
  36. global entry
  37. global first
  38. global op
  39. print("Welcome to Spencer's Calculator v2.\n Either enter the first number you wish to work with and hit 'Enter' or type 'help' for what you can do.")
  40. first = input("Enter a float value or a command: ")
  41. if first == 'commands':
  42. commands()
  43. numeral(first)
  44. main('0',0,'0')
Add Comment
Please, Sign In to add comment