Thursday, 20 January 2022

Python-sLIP3B-Write a python script to define a class student having members roll no, name, age, gender. Create a subclass called Test with member marks of 3 subjects. Create three objects of the Test class and display all the details of the student with total marks.

 Write a python script to define a class student having members roll no, name, age, gender. Create a subclass called Test with member marks of 3 subjects. Create three objects of the Test class and display all the details of the student with total marks.

 

class Student:

 def GetStudentData(self):

  self.RollNo=int(input("\nEnter Student Roll No:"))

  self.Name=input("Enter Student Name:")

  self.Age=int(input("Enter Student Age:"))

  self.Gender=input("Enter Student Gender:")

 

 def PutStudentData(self):

  print("Student Roll No:",self.RollNo)

  print("Student Name:",self.Name)

  print("Student Age:",self.Age)

  print("Student Gender:",self.Gender)

 

class Test(Student):

 def GetMarksData(self):

  self.M1=int(input("Enter Marks of M1 Subject"))

  self.M2=int(input("Enter Marks of M2 Subject"))

  self.M3=int(input("Enter Marks of M3 Subject"))

 

 def PutMarksData(self):

    print("M1 Marks:", self.M1) 

    print("M2 Marks:", self.M2)

    print("M3 Marks:", self.M3)

    print("Total Marks:",self.M1+self.M2+self.M3)

 

n=int(input("Enter How many students"))

s=[]

for i in range(0,n):

 X=input("Enter Object Name:")

 s.append(X)

 print(s)

  

for j in range(0,n):

 s[j]=Test()

 s[j].GetStudentData()

 s[j].GetMarksData()

 print("\nDisplay Details of Student")

 s[j].PutStudentData()

 s[j].PutMarksData()