To print the report cards of 30 students of your class.
don't spam
Answers
Answered by
2
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()
Similar questions