Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # hmw
- # python 3.7
- amount = input("Enter number of assignments to input : ")
- amount_var = int(amount)
- # they're empty lists because we're going to insert the numbers later
- recieved_points = [] # a list for points u got
- possible_points = [] #a list of possible points
- number_var = int(0)
- while True: # while true statement to keep asking the question until breaks
- a = amount_var - int(1)
- amount_var = a # i used this for when amount of questions is over it breaks like in line 24
- b = number_var + int(1)
- number_var = b # this will be used for printing to show assignment number
- # check here to see if they reach the amount of questions (so like 5 assigments sets, then it will break at 5
- if a == -1: # breaks loops goes to sums up the numbers
- break
- # v the \n is for spacing
- 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
- possible_p = "\nEnter number of points possible for assignment {number_a} : ".format(number_a = b) # same for this
- rec = input(recieved) # get user input
- pos = input(possible_p)
- 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)
- possible_points.insert(0,(float(pos)))# same for this
- add_up_rec = sum(recieved_points) # adds up the numbers in the recieved points to get the total amount we got
- add_up_pos = sum(possible_points) # adds up what we could've got (possible points)
- 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
- # ^ 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
- print ("Your total amount of points is {total_rec} out of {pos} points, or %{percentage}.".format( # print the final things
- total_rec = add_up_rec,
- pos = add_up_pos,
- percentage = final_percent
- ))
- 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