Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify this code I want this code to print the average grade letter import random # Function definition to calculate average def calculate_average(numbers): return sum(numbers)

Modify this code

I want this code to print the average grade letter

import random # Function definition to calculate average def calculate_average(numbers): return sum(numbers) / len(numbers) # Function definition to assign grade acoording to random number def get_letter_grade(number): if number < 60: return "F" elif number < 70: return "D" elif number < 80: return "C" elif number < 90: return "B" else: return "A"

numbers = [] for i in range(5): number = random.randint(50, 100) numbers.append(number) print(f"Random number {i+1}: {number}")

average = calculate_average(numbers) print(f"Average: {average}")

for number in numbers: letter_grade = get_letter_grade(number) print(f"Grade for {number}: {letter_grade}")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions

Question

Connect with your audience

Answered: 1 week ago