Advertisement
GameNationRDF

Python Digit Calculator

Jan 7th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. # Digit calculator. Code by Umut Bilgic.
  2. # 1/8/2014 12:42 AM
  3.  
  4. import math
  5.  
  6. def calc(a,n):
  7.     return ((math.ceil(n*math.log(a,10)))+1)
  8. def blank():
  9.     print ("")
  10. def seperate():
  11.     print ("________________________________")
  12.  
  13. print ('''This program lets you calculate the number of digits
  14. the number "a^n" has.''')
  15.  
  16. while True:
  17.    
  18.     blank()
  19.     user_a = int(input("a = "))
  20.     blank()
  21.     user_n = float(input("n = "))
  22.     blank()
  23.     print (calc(user_a, user_n))
  24.     blank()
  25.  
  26.     user_e = str(input("Would you like to exit (y/n): "))
  27.     blank()
  28.     if user_e == ("y") or user_e == ("Y") or user_e == ("yes") or user_e == ("YES"):
  29.         sys.exit("User exit.")
  30.     elif user_e == ("n") or user_e == ("N") or user_e == ("no") or user_e == ("NO"):
  31.         pass
  32.     else:
  33.         seperate()
  34.         print ("Did not recognized, continuing...")
  35.     seperate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement