Advertisement
Resenex

Untitled

Apr 25th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. 8.6
  2. ----------------------
  3. gpaa = 0
  4. i = int(input('How many classes are you taking? '))
  5. def GPAcalc(x, y):
  6. x = x.upper()
  7. if x == 'A':
  8. return 4 + y
  9. if x == 'B':
  10. return 3 + y
  11. if x == 'C':
  12. return 2 + y
  13. if x == 'D':
  14. return 1 + y
  15. if x == 'F':
  16. return 0 + y
  17. else:
  18. return 'Invalid'
  19. for j in range(i):
  20. grade = input('Enter your letter grade: ')
  21. weight = int(input('Is it weighted? (1 = yes) '))
  22. gpa = GPAcalc(grade,weight)
  23. print('Your GPA score is: ' + str(gpa))
  24. gpaa = gpaa + gpa
  25. avg = (gpaa / i)
  26. print('Your GPA score is a ' + str(avg))
  27.  
  28.  
  29. Assignment 8
  30. ---------------------------
  31. '''Initializing'''
  32. day = 0
  33. month = 0
  34. year = 0
  35. leap = 0
  36. left = 0
  37. decision = 0
  38. dayinmonth = 0
  39. dayinyear = 365
  40. daysleft = 0
  41. if year % 4 == 0:
  42. dayinmonth = dayinmonth + 1
  43. leap = 1
  44. '''Defining functions'''
  45. def leap_year():
  46. if year % 4 != 0:
  47. leap = 0
  48. else:
  49. dayinyear = dayinyear + 1
  50. leap = 1
  51. def number_of_days():
  52. if month == 2 and leap == 1:
  53. return 29
  54. if month == 1 or 3 or 5 or 7 or 8 or 10 or 12:
  55. return 31
  56. if month == 2 and leap != 1:
  57. return 28
  58. if month != 1 or 2 or 3 or 5 or 7 or 8 or 10 or 12:
  59. return 30
  60. def days_left():
  61. if month == 1:
  62. daysleft = (dayinyear - day)
  63. elif month == 2:
  64. daysleft = (dayinyear - day - 31)
  65. elif month == 3:
  66. daysleft = (dayinyear - day - 59)
  67. elif month == 4:
  68. daysleft = (dayinyear - day - 90)
  69. elif month == 5:
  70. daysleft = (dayinyear - day - 120)
  71. elif month == 6:
  72. daysleft = (dayinyear - day - 151)
  73. elif month == 7:
  74. daysleft = (dayinyear - day - 181)
  75. elif month == 8:
  76. daysleft = (dayinyear - day - 212)
  77. elif month == 9:
  78. daysleft = (dayinyear - day - 243)
  79. elif month == 10:
  80. daysleft = (dayinyear - day - 273)
  81. elif month == 11:
  82. daysleft = (dayinyear - day - 304)
  83. elif month == 12:
  84. daysleft = (dayinyear - day - 334)
  85. return daysleft
  86. '''Inputs'''
  87. print('Please enter a date')
  88. day = int(input('Day: '))
  89. month = int(input('Month: '))
  90. year = int(input('Year: '))
  91. print(' ')
  92. ('')
  93. decision = int(input('Menu:\n1) Calculate the number of days in the given month.\n2) Calculate the number of days left in the given year.\n'))
  94. if decision == 1:
  95. print(number_of_days())
  96. else:
  97. print(days_left())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement