Skip to content

Commit

Permalink
Create joe_g.py
Browse files Browse the repository at this point in the history
  • Loading branch information
joegeorge022 authored Dec 1, 2024
1 parent dbb46a5 commit f1a4781
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Day-15/joe_g.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
student_scores = {"Apple":9,"Mango":7,"Orange":8,"Watermelon":10}

def average(i):
total = sum(i.values()) # Here the total value is set as the sum of all values
count = len(i) # Here the total count is set to the number of values
average = total/count # Avg = total/count
return average

print("Average Score:",average(student_scores)) # The function average() is used to find the average score.



def find_highest_score(scores):
highest_student = None
highest_score = 0
for student, score in scores.items():
if score > highest_score:
highest_score = score
highest_student = student
return highest_student, highest_score

highest_student, highest_score = find_highest_score(student_scores)
print(f"Highest Score: {highest_student} with {highest_score}")



for student in student_scores:
print(f"{student}: {student_scores[student]}")

for i,j in student_scores.items():
print(f"{i} has a score of {j}.")

0 comments on commit f1a4781

Please sign in to comment.