Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Student():
- def __init__(self, name, age, list_of_marks):
- self.name = name
- self.age = age
- self.marks = {
- "english" : list_of_marks[0],
- "science" : list_of_marks[1],
- "maths" : list_of_marks[2]
- }
- def get_all_subjects(self):
- return list(self.marks.keys())
- def check_subject(self, subject):
- return subject in self.marks.keys()
- #if subject in self.marks.keys():
- # return True
- #else:
- # return False
- def getAverage(self):
- return sum(self.marks.values())/len(self.marks.values())
- batch = []
- for i in range(3):
- name = input("Enter name of student: ")
- age = input("Enter age of student: ")
- list_of_marks = input("Enter list of marks(seprated by ','): ").split(",")
- stu = Student(name, age, list_of_marks)
- batch.append(stu)
- for stu in batch:
- print(stu.name,"has",stu.marks["maths"],"marks in maths")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement