Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import easygui
- winTitle = "Dollar To Time Converter"
- convUnitsUp = (46, 5, 182/5, 1000, 1000, 65, 540/65, 4567/540, 3)
- unitNames = ("minute(s)", "day(s)", "week(s)", "year(s)", "millenium/a", "million year(s)", "Cretacean(s)", "Cambria(s)", "Earth(s)", "Universe(s)")
- oneK = "000"
- divisors = (("k", oneK), ("M", oneK * 2), ("G", oneK * 3), ("T", oneK * 4))
- finalString = ""
- # $ 1 = 1 min
- # 46 mins = 1 day
- # 5 days = 1 week
- # 182 days = 1 year
- # 1000 years = 1 millenium
- # 1000 millenia = 1 ice age
- # 65 ice ages = 1 Cretaceous
- # 540 ice ages = 1 Cambrian
- # 4567 ice ages = 1 Earth
- # 3 Earths = 1 Universe
- currencyUnit = [-1, -1]
- while currencyUnit[0] == -1 and currencyUnit[1] == -1:
- inValue = easygui.enterbox("Enter a dollar amount, followed by USD or HKD", winTitle)
- currencyUnit = [inValue.find("USD"), inValue.find("HKD")]
- for i in divisors:
- inValue = inValue.replace(i[0], i[1])
- # In any case, parse integer (or just crop off the USD/HKD!)
- print("converting {0}".format(inValue))
- currencyValue = int(inValue[:-4])
- print(currencyValue)
- if not currencyUnit[0] == -1:
- # if USD, divide by 7.8
- currencyValue = currencyValue * 7.8
- break
- elif not currencyUnit[1] == -1:
- break
- j = 0
- for i in convUnitsUp:
- currencyValue = currencyValue / i
- if currencyValue < 1:
- currencyValue = currencyValue * i
- break
- j = j+1
- finalString = "That amount of money will buy lunch for {0} {1}.".format(round(currencyValue, 3), unitNames[j])
- easygui.msgbox(finalString, winTitle)
Advertisement
Add Comment
Please, Sign In to add comment