Advertisement
MrsMcLead

ECS GPA

Nov 19th, 2013
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 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="GPA")
  7. w.pack()
  8.  
  9. grade1 = tkinter.simpledialog.askinteger("Grade 1", "Please enter the number for your first grade (A=4, B=3, C=2, D=1, F=0)")
  10. #1. add 3 more statments like the one above so your program will ask for 4 grades total.
  11.        
  12. sum = grade1;
  13. #2. edit the line above to add up all the grades from #1;
  14.        
  15. gpa = sum;
  16. #3. edit the line above to divide the sum by 4.0
  17.  
  18. tkinter.messagebox.showinfo("GPA", "Your GPA is " + str(gpa))
  19.  
  20. #Answer questions 4-6 on paper.
  21. #4. What's the most number of F's you can get and still get a 2.0?
  22. #5. What would you have to change in the code if it was supposed to work with
  23. #   6 grades instead of 4?
  24. #6. In #3, what happens if you try to divide by 4 instead of 4.0?  Try it both
  25. #   ways with the grades, 4, 3, 2, 1.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement