Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Having trouble with python! Write a program to build a list of grades, print the

ID: 3601754 • Letter: H

Question

Having trouble with python!

Write a program to build a list of grades, print them out, add to them and count occurrences, and find the amount of the 2-digit grade values. Here are the criteria a) Your program “L6QI initials.py" must start with a commented ID Box AND include a comment that indicates the e of the program. EACH of the five functions in your program must state its purpose in comments too The main function in your program must be named: test_grades ).It has been provided for you. Copy this function into your program EXACTLY as written: # Main function - Test all of the helper functions def test_grades ): grade-list create-grades (11) print_rows (grade_list) add grade (grade 1ist) print_rows (grade_list) print ("Amount of 2-digit valuescount_grades (grade_list)) As you can see, test_grades calls FOUR helper functions namely: create grades (amount): Create and return a list of amount randomly selected integers between (and including) 0 and 100 print rows (grade list): ng 4 space separated values in each row. The last Print all of qrade list showi row may have fewer than 4 values in it. add_grade (grade_list): Prompt the user for a grade between (and including) 0 and 100 and append it to grade list. Count how many times the grade occurs in grade_list and print out the result. NOTE: Error checking is not required for this input. count_grades (grade_list): Calculate and return the amount of 2-digit grades in grade_list (ie. grades between 10 and99). Assume grade_list will contain at least one value.

Explanation / Answer

Hi,

The below Pythonic 3 Code is written to satify all the criteria mentioned in the question.

Test this program with giving test_grades() at the command line and find the result!!

import random
#Main Function - Test all of the helper functions
def test_grades():
grade_list=create_grades(11)
print_rows(grade_list)

add_grade(grade_list)
print_rows(grade_list)

print("Amount of 2-digit values =",count_grades(grade_list))

#Create a list of random selected integers with "amount" as length of the list
def create_grades(amount):
list1=[]
for x in range(amount):
list1.append(random.randint(0,100))
return list1

#print the list with 4 space separated values in a row
def print_rows(grade_list):
for i in range(len(grade_list)):
if i%4==0:
print()
print (grade_list[i],end=' ')
print()

#Prompt user for a grade and append to the list, besides counting the occurrence of the grade in the list
def add_grade(grade_list):
grade=int(input("Enter a grade between 0 and 100:"))
grade_list.append(grade)
print("%d occurs %d times " %(grade,grade_list.count(grade)))

#Calculate and return the amount of 2-digit grades in the list
def count_grades(grade_list):
count=0
for i in grade_list:
if i >=10 and i<=99:
count+=1
return count

Happy coding,

Thanks and Regards,

Hema.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote