Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random #import from the random function
- grades = [] #create empty list called grades
- tens = [] #create empty list called tens
- lowscore = []
- for x in range(0, 30): # loop range 30
- grades.append(random.randint(0,10)) #append in grades a random number 0 - 10
- print(grades)
- for item in grades: #for every item in grades, if equal to 10, put in tens list
- if item == 10:
- tens.append(item)
- elif item <= 3:
- lowscore.append(item) #for every item in grades if lower then 3 put in lowscore list
- print(tens)
- top_scorers = len(tens) #top_scorers is equal to the length of tens list(int)
- low_scorers = len(lowscore) #low_scorers is equal to the length of lowscore list
- print(" {} student/s have scored the perfect score".format(top_scorers))
- print(" {} student/s have scored lower then 3".format(low_scorers))
- #find a way to display the most populair item
- from collections import Counter #import Counter from collections
- order_drinks = ["Tea","Coffee","Tea","Tea","Coffee","Hot Chocolate","Tea"] #this is the list
- i = Counter(order_drinks) #using a class constructor __init__ ?
- print(i.most_common()) #display the most common value, in order from high to low
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement