To print the report cards of 30 students of your class.
don't spam
Share
To print the report cards of 30 students of your class.
don't spam
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
from random import randrange, sample
from string import ascii_lowercase
def gen_reports():
reports = {}
subjects = ["English", "Maths", "Science", "Economics", "History"]
for x in range(30):
marks = [randrange(10, 99) for n in range(5)]
reports[f"student_{x}"] = {
"name": "".join(sample(ascii_lowercase, 5)),
"marks": list(zip(subjects, marks))
}
return reports
reports = gen_reports()
for k in reports.keys():
student = reports[k]
print("Name:", student["name"])
for subject in student["marks"]:
print(f"{subject[0]}:", subject[1])
print()