Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- This is a currency exchanger between Japanese Yen and US dollars.
- The exchanger works both ways.
- Asks which way the user would like to exchange, then the amount of money they have, and finally the code prints out the value of that amount of money.
- '''
- usd = 1
- yen = 111.44
- numbers = ['1','2','3','4','5','6','7','8','9','0']
- print("Welcome to the Japanese Yen to United States' Dollar Currency Exchanger.\n")
- way = input("Would you like to change Japanese yen into US dollars, or the other way around? \nPlease type a 1, for Yen to US dollars, and a 2 for US dollars into Yen. ")
- print("")
- if way.lower() != "1" or "2":
- while way.lower() != "1" or way.lower() != "2":
- if way.lower() == "1" or way.lower() == "2":
- break
- way = input("Please type a 1, for Yen to US dollars, and a 2 for US dollars into Yen. ")
- money = input("How much money do you have? ")
- def checkMoney(money):
- '''
- (str) -> (str)
- Checks to make sure that there are no weird characters.
- '''
- for x in money:
- if x not in numbers:
- money = input("How much money do you have? ")
- checkMoney(money);
- checkMoney(money);
- print(money)
- money = float(money)
- def ytd(money):
- '''
- (float) -> (float)
- Turns Japanese Yen into United States' Dollars.
- '''
- amount = money / yen
- amount *= 100
- amount = int(amount)
- amount /= 100
- print(amount)
- def dty(money):
- '''
- (float) -> (float)
- Turns United States' Dollars into Japanese Yen.
- '''
- amount = money * yen
- amount = int(amount)
- print(amount)
- if way.lower() == "1":
- ytd(money);
- elif way.lower() == "2":
- dty(money);
- else:
- print("error")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement