Advertisement
MrsMcLead

ECS Exchange

Nov 19th, 2013
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.89 KB | None | 0 0
  1. from tkinter import*
  2. import tkinter.simpledialog
  3. import tkinter.messagebox
  4.  
  5. root = Tk()
  6. w = Label(root, text="Money Exchange")
  7. w.pack()
  8.  
  9. #0 follow along as I show you how to write a function that converts from
  10. #pesos to dollars (multiply pesos by 0.073715 to get dollars)
  11.  
  12.  
  13.  
  14.  
  15. #1 finish dollars to pesos (multiply dollars by 13.56576 to get pesos)
  16. def dollarstopesos(dollars):
  17.  
  18.     return
  19.  
  20. #2 finish euros to dollars (multiply by 1.26800)
  21. def eurostodollars(euros):
  22.  
  23.     return
  24.  
  25. #3 finish dollars to euros (multiply by 0.788643533)
  26. def dollarstoeuros(dollars):
  27.  
  28.     return
  29.  
  30. #4 write a method called dollarstoyen (multiply by 92.9195317)
  31. #make sure to add code at the bottom to test your function (test it with 30
  32. #dollars).
  33.  
  34. #5 This is EXTRA CREDIT.  In real life, places that exchange money charge fees.
  35. #Write a function called exchangedollarstoeuros().  First it charges 1 dollar
  36. #and then it does the conversion.  
  37.  
  38. #6 EXTRA EXTRA Credit - some places charge 1% of your money to do the exchange
  39. #instead of a flat fee.  Write code to do this.
  40.  
  41. #Program starts running here:
  42. dollars = pesostodollars(100)
  43. tkinter.mesagebox.showinfo("pesostodollars", "100 pesos = " + str(dollars) + " dollars")
  44.  
  45. pesos = dollarstopesos(10)
  46. tkinter.mesagebox.showinfo("dollarstopesos", "10 dollars = " + str(pesos) + " pesos")
  47.  
  48. euros = dollarstoeuros(50)
  49. tkinter.mesagebox.showinfo("dollarstoeuros", "50 dollars = " + str(euros) + " euros")
  50.  
  51. dollars = eurostodollars(20)
  52. tkinter.mesagebox.showinfo("eurostodollars", "20 euros = " + str(dollars) + " dollars")
  53.  
  54. # If your program works, you should get the following:
  55. #
  56. #   100 pesos = 7.3715 dollars
  57. #   10 dollars = 135.6576 pesos
  58. #   50 dollars = 39.43217665 euros
  59. #   20 euros = 25.36 dollars  
  60. #  
  61. #   30 dollars = 2787.585951 yen
  62. #
  63. #   Extra Credit:
  64. #   50 dollars =  38.643533117 euros
  65. #   Extra Extra Credit:
  66. #   50 dollars = 39.0378548835 euros
  67. #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement