Advertisement
xample

Home work explained

Dec 14th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.24 KB | None | 0 0
  1.  
  2. # hmw
  3. # python 3.7
  4.  
  5. amount = input("Enter number of assignments to input : ")
  6. amount_var = int(amount)
  7.  
  8. # they're empty lists because we're going to insert the numbers later
  9. recieved_points = [] # a list for points u got
  10. possible_points = [] #a list of possible points
  11. number_var = int(0)
  12.  
  13.  
  14.  
  15. while True: # while true statement to keep asking the question until breaks
  16.     a = amount_var - int(1)
  17.     amount_var = a # i used this for when amount of questions is over it breaks like in line 24
  18.    
  19.    
  20.     b = number_var + int(1)
  21.     number_var = b # this will be used for printing to show assignment number
  22.     # check here to see if they reach the amount of questions (so like 5 assigments sets, then it will break at 5
  23.  
  24.     if a == -1: # breaks loops goes to sums up the numbers
  25.         break
  26.     #             v the \n is for spacing
  27.     recieved = "\nEnter number of points received for assignment {number} : ".format(number = b) # use this so i dont have to keep printing over and over again
  28.     possible_p = "\nEnter number of points possible for assignment {number_a} : ".format(number_a = b) # same for this
  29.     rec = input(recieved) # get user input
  30.     pos = input(possible_p)
  31.     recieved_points.insert(0,(float(rec))) # use float command so like if its 5.23 out of 10 it will store with no problem (or can be a number like 5 out of 10 both works)
  32.     possible_points.insert(0,(float(pos)))# same for this
  33.    
  34.    
  35.        
  36. add_up_rec = sum(recieved_points) # adds up the numbers in the recieved points to get the total amount we got
  37. add_up_pos = sum(possible_points) # adds up what we could've got (possible points)
  38. final_percent = int(add_up_rec / add_up_pos * 100) # to get percent its simple, dividing the sum of rec and possible points then multiply by 100 to get percent
  39. #            ^ we use int command here and not float because if we use float we will get like 23.00000000001 but int gives us like 23 same goes for percent
  40. print ("Your total amount of points is {total_rec} out of {pos} points, or %{percentage}.".format( # print the final things
  41.     total_rec = add_up_rec,
  42.     pos = add_up_pos,
  43.     percentage = final_percent
  44.  
  45.     ))
  46. input() # to stop the program from instantly exiting out so we can view the score
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement