Advertisement
Arcot

ch11 ex1

Dec 26th, 2021
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. ##1
  2. class Student():
  3.  
  4.     def __init__(self, name, age, list_of_marks):
  5.         self.name = name
  6.         self.age = age
  7.         # list_of_subjects = ["english", "science", "math"] ## not really required because it is redundant anyways but you can use it because it is in the question.
  8.         self.marks = {
  9.             "english": list_of_marks[0],
  10.             "science": list_of_marks[1],
  11.             "maths": list_of_marks[2],
  12.         }
  13.  
  14. b = Student("Bruce", 24, [92, 95, 99])
  15. a = Student("Alfred", 42, [29, 59, 88])
  16.  
  17. # print(b.marks["maths"])
  18. # print(a.marks["maths"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement