class student:
marks=[]
def getData (self,name,rn,age,gender,m1,m2,m3):
student.name = name
student.rn = rn
student.age = age
student.gender = gender
student.marks.append(m1)
student.marks.append(m2)
student.marks.append(m3)
def displayData(self):
print("Name is ",student.name)
print("Roll No. is ",student.rn)
print("Age is ",student.age)
print("Gender is ",student.gender)
print("Marks are ",student.marks)
print("Total marks are ",self.total())
print("Percentage is ",round(self.per(),2))
def test(self):
print("Marks in 1st subject ",student.marks[0])
print("Marks in 2nd subject ",student.marks[1])
print("Marks in 3rd subject ",student.marks[2])
def total(self):
return (m1+m2+m3)
def per(self):
return ((m1+m2+m3)/3)
name = input("Enter the Name of the Student:")
rn = input("Enter the Roll Number:")
age = input("Enter the Age:")
gender = input("Enter the Gender:")
m1 = int(input("Enter the marks in first subject:"))
m2 = int(input("Enter the marks in second subject:"))
m3 = int(input("Enter the marks in third subject:"))
s1 = student()
s1.getData(name,rn,age,gender,m1,m2,m3)
s1.test()
s1.displayData()
Enter the Name of the Student:Rahul
Enter the Roll Number:101
Enter the Age:24
Enter the Gender:Male
Enter the marks in first subject:68
Enter the marks in second subject:78
Enter the marks in third subject:88
Marks in 1st subject 68
Marks in 2nd subject 78
Marks in 3rd subject 88
Name is Rahul
Roll No. is 101
Age is 24
Gender is Male
Marks are [68, 78, 88]
Total marks are 234
Percentage is 78.0
0 Comments:
Post a Comment