Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Digit calculator. Code by Umut Bilgic.
- # 1/8/2014 12:42 AM
- import math
- def calc(a,n):
- return ((math.ceil(n*math.log(a,10)))+1)
- def blank():
- print ("")
- def seperate():
- print ("________________________________")
- print ('''This program lets you calculate the number of digits
- the number "a^n" has.''')
- while True:
- blank()
- user_a = int(input("a = "))
- blank()
- user_n = float(input("n = "))
- blank()
- print (calc(user_a, user_n))
- blank()
- user_e = str(input("Would you like to exit (y/n): "))
- blank()
- if user_e == ("y") or user_e == ("Y") or user_e == ("yes") or user_e == ("YES"):
- sys.exit("User exit.")
- elif user_e == ("n") or user_e == ("N") or user_e == ("no") or user_e == ("NO"):
- pass
- else:
- seperate()
- print ("Did not recognized, continuing...")
- seperate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement