Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import*
- import tkinter.simpledialog
- import tkinter.messagebox
- root = Tk()
- w = Label(root, text="Money Exchange")
- w.pack()
- #0 follow along as I show you how to write a function that converts from
- #pesos to dollars (multiply pesos by 0.073715 to get dollars)
- #1 finish dollars to pesos (multiply dollars by 13.56576 to get pesos)
- def dollarstopesos(dollars):
- return
- #2 finish euros to dollars (multiply by 1.26800)
- def eurostodollars(euros):
- return
- #3 finish dollars to euros (multiply by 0.788643533)
- def dollarstoeuros(dollars):
- return
- #4 write a method called dollarstoyen (multiply by 92.9195317)
- #make sure to add code at the bottom to test your function (test it with 30
- #dollars).
- #5 This is EXTRA CREDIT. In real life, places that exchange money charge fees.
- #Write a function called exchangedollarstoeuros(). First it charges 1 dollar
- #and then it does the conversion.
- #6 EXTRA EXTRA Credit - some places charge 1% of your money to do the exchange
- #instead of a flat fee. Write code to do this.
- #Program starts running here:
- dollars = pesostodollars(100)
- tkinter.mesagebox.showinfo("pesostodollars", "100 pesos = " + str(dollars) + " dollars")
- pesos = dollarstopesos(10)
- tkinter.mesagebox.showinfo("dollarstopesos", "10 dollars = " + str(pesos) + " pesos")
- euros = dollarstoeuros(50)
- tkinter.mesagebox.showinfo("dollarstoeuros", "50 dollars = " + str(euros) + " euros")
- dollars = eurostodollars(20)
- tkinter.mesagebox.showinfo("eurostodollars", "20 euros = " + str(dollars) + " dollars")
- # If your program works, you should get the following:
- #
- # 100 pesos = 7.3715 dollars
- # 10 dollars = 135.6576 pesos
- # 50 dollars = 39.43217665 euros
- # 20 euros = 25.36 dollars
- #
- # 30 dollars = 2787.585951 yen
- #
- # Extra Credit:
- # 50 dollars = 38.643533117 euros
- # Extra Extra Credit:
- # 50 dollars = 39.0378548835 euros
- #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement