# Exercise Solution on Object Oriented Programming

Exercise Solution
``````class student_kit():
now=200  # Numbe of working days, class attribute
def __init__(self,name,section):
self.name=name
self.section=section

def marksheet(self,mark1,mark2,mark3):
self.mark1=mark1
self.mark2=mark2
self.mark3=mark3
self.sum_marks=self.mark1 + self.mark2 + self.mark3
return mark1+mark2+mark3

def attendance(self,nop):
self.percentage_of_attendace=(nop/student_kit.now)*100
print("Name of student is {}".format(self.name))
print("No of days {} was absent is {}".format(self.name,student_kit.now-nop))
print("percentage of attendance {}".format(self.percentage_of_attendace))

def certificate(self):
print("\n\n#### Certificate #####\n")
print("Total marks obtaind by",self.name, " is : ",self.sum_marks)
print(" Attendace ",self.percentage_of_attendace,"%")  #access data from other methods

kalu=student_kit("Kalu","A")   #object kalu is created
print("Student Name:",kalu.name," of Section :",kalu.section)
a=int(input("\n Enter maths marks: "))
b=int(input("Enter physics marks: "))
c=int(input("Enter Chemistry marks: "))

p=int(input("Enter no of days present: "))

kalu.attendance(p)
print("Total Mark ",kalu.marksheet(a,b,c))
kalu.certificate()

``````
Keep your student_kit class in a separate file ( student_kit.py ) . Create a new file using the above code for creating three student inputs. Call the class student_kit from your new file and use the methods to show marksheet , certificate , attendance etc for each student.Use this code in your new file to link the class.

student.py
``````# Create the dictionary with three students
# For each student take marks in three subjeccts and attendance
# For each student display certificate using student_kit.

from student_kit import student_kit

my_dict={}

for i in range(0,3):
n=input("Student Name : ")
a=int(input("\n Enter maths marks: "))
b=int(input("Enter physics marks: "))
c=int(input("Enter Chemistry marks: "))

p=int(input("Enter no of days present: "))

my_dict.update({n:[a,b,c,p]})

print(my_dict)

for i in my_dict:
obj=student_kit(i,"A")  #object  is created
obj.attendance(my_dict[i])
print("Total Mark ",obj.marksheet(my_dict[i],my_dict[i],my_dict[i]))
obj.certificate()``````
student_kit.py
``````class student_kit():
now=200 # Numbe of working days, class attribute
def __init__(self,name,section):
self.name=name
self.section=section

def marksheet(self,mark1,mark2,mark3):
self.mark1=mark1
self.mark2=mark2
self.mark3=mark3
self.sum_marks=self.mark1 + self.mark2 + self.mark3
return mark1+mark2+mark3

def attendance(self,nop):
self.percentage_of_attendace=(nop/student_kit.now)*100
print("Name of student is {}".format(self.name))
print("No of days {} was absent is {}".format(self.name,student_kit.now-nop))
print("percentage of attendance {}".format(self.percentage_of_attendace))

def certificate(self):
print("\n\n#### Certificate #####\n")
print("Total marks obtaind by",self.name, " is : ",self.sum_marks)
print(" Attendace ",self.percentage_of_attendace,"%") #access data from other methods
`````` plus2net.com