Question
Below is the starter code I have. I need help getting program to display number of A students, number of B students, and number of
Below is the starter code I have.
I need help getting program to display number of A students, number of B students, and number of A and B students.
Also need to percentage to be displayed on side of number like follows it shows now but still says 0 and 0 percent.
I also need a * displayed next to B students and two ** displayed next to A students
import random
def main():
size = 11
lst_stu_names = ["Vernon", "Domenic", "Michael", "Celena",
"Odis", "Rufus", "Rose", "Cheryll",
"Mignon", "Monte", "Ralph"]
lst_stu_grades = [""] * size
for i in range(size):
lst_stu_grades[i] = random.choice(["A", "B", "C", "D", "F"])
num_A_stu = 0
num_B_stu = 0
tot_rec = 0
print(" # Student\tGrade --------------------------")
for i in range(size):
tot_rec += 1
grade = lst_stu_grades[i]
st_name = lst_stu_names[i]
message = " "
print(f"{tot_rec:>2d}. {st_name:<11}\t{grade}{message}")
print()
print(f"Total Students : {size:>2}")
print(f"'A' Students : {num_A_stu:>2} ({num_A_stu/tot_rec:>.1%})")
print(f"'B' Students : {num_B_stu:>2} ({num_B_stu*100/tot_rec:>.1f}%)")
print(f"'A', 'B' Students: {num_A_stu:>2} ({(num_A_stu+num_B_stu)/tot_rec:>.1%})")
main()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started