135k views
5 votes
write a program that uses the keys(), values(), and/or items() dict methods to find statistics about the student grades dictionary. find the following: print the name and grade percentage of the student with the highest total of points. find the average score of each assignment. find and apply a curve to each student's total score, such that the best student has 100% of the total points.

User Mwthreex
by
7.3k points

2 Answers

6 votes
grades = {
'Alice': [85, 92, 88, 93],
'Bob': [90, 82, 78, 85],
'Charlie': [89, 94, 90, 87],
'Dave': [78, 88, 93, 82],
'Eve': [80, 85, 89, 95],
}

# Print the name and grade percentage of the student with the highest total of points.
highest_total = 0
highest_student = ''
for student, scores in grades.items():
total = sum(scores)
if total > highest_total:
highest_total = total
highest_student = student

print(f'{highest_student} scored {highest_total} points, which is {(highest_total / (len(scores)*100)):.2%} of the total possible points.')

# Find the average score of each assignment.
num_assignments = len(next(iter(grades.values())))
averages = []
for i in range(num_assignments):
assignment_scores = [scores[i] for scores in grades.values()]
averages.append(sum(assignment_scores) / len(assignment_scores))

print(f'The average score of each assignment is {", ".join(map(str, averages))}.')

# Find and apply a curve to each student's total score, such that the best student has 100% of the total points.
best_student_total = sum(grades[highest_student])
for student, scores in grades.items():
curve = (sum(scores) / len(scores)) / (best_student_total / len(scores))
curved_total = sum(score * curve for score in scores)
grades[student] = curved_total

print('Curved grades:')
for student, score in grades.items():
print(f'{student}: {score:.2f}')
User Nsgulliver
by
7.4k points
1 vote

Answer:

This should be right

Step-by-step explanation:

import random

import time

def word_counts():

def time_convert(sec):

mins = sec // 60

sec = sec % 60

hours = mins // 60

mins = mins % 60

print("Time Lapsed = {0}:{1}:{2}".format(int(hours),int(mins),sec))

words = []

word = input("Please enter a starting word: ")

print("The monkey is looking for your word...")

words.append(word)

start_time = time.time()

final_word = []

def find_word():

dict = {1:'a',2:'b',3:'c',4:'d',5:'e',6:'f',7:'g',8:'h',9:'i',10:'j',11:'k',12:'l',13:'m',14:'n',15:'o',16:'p',17:'q',18:'r',

19:'s',20:'t',21:'u',22:'v',23:'w',24:'x',25:'y',26:'z',27:' '}

word = []

count = 0

while count < (len(words[0])):

num = random.randint(1,27)

word.append(dict[num])

if word[0] == words[0]:

final_word.append(words[0])

count = count+1

check = ''.join(word)

return check

word_counter = 0

z = ''

numb = 0

while numb < 1:

if word_counter > 1000000:

print("Your word was to hard the monkey killed himself")

return

if z == words[0]:

print("YAY!! the monkey found your word it took " + str(word_counter) + " cycles to find "+ str(words[0]))

numb = numb+1

end_time = time.time()

time_lapsed = end_time - start_time

(time_convert(time_lapsed))

else:

word_counter = word_counter + 1

z = find_word()

x = 0

while x < 1:

word_counts()

User NikRED
by
7.9k points