Student ID Numbers
Python
25 pts
Student ID Numbers
Create a class Student with two class attributes: school = "Keren Secondary School" and count = 0.
In __init__(self, name):
- store the name,
- increase
Student.countby 1, - give the student
self.id_numberequal to the new count (so the first student gets 1, the second 2, and so on).
Create selam, merhawi and abel (in that order), print each as id. name, then print the total.
Expected output:
1. Selam 2. Merhawi 3. Abel Total at Keren Secondary School: 3
Checklist
- Define a class
Studentwith the class attributesschoolandcount. - In
__init__, store the name, increase the shared counter by 1 and give the student anid_numberequal to the new count. - Create
selam,merhawiandabel, in that order. - Print each student as
id. name, then print the total.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
