Define a class student in python with the following description: Name, class, admission number, marks (in 5 subjects) Methods to be defined:

- A function get_marks() to input the marks in 5 subjects from the user.
- A function percent() to calculate the percentage of the student.
- A function show_data() to show the content of all the data members.

In [4]:
class student(object):
    '''Class to define a student object with the following attributes:
            name, class, admno, marks (for 5 subjects)
        And the following methods:-
            get_marks() : To input marks
            percent() : To calculate and print percentage
            show_data() : To print all information'''
    def __init__(self,name,Class,):
        self.name = name
        self.Class = Class
        self.admno = admno
        self.marks = []
    def get_marks(self):
        for i in xrange(1,6):
            self.marks.append(raw_input('Enter marks in %d subject'%i))
    def percent(self):
        print str(sum(self.marks)/5.0)+'%'
    def show_data(self):
        print 'Name: ' + self.name + '\n' + 'Class: ' + str(self.Class) + '\n' + 'Admission No: ' + str(self.admno)
        for i in xrange(1,6):
            print 'Marks in %d subject: '%i

In [ ]: