Class in Python

Class is a user defined datatype in which the user can define his/her own variables and functions. The syntax of the class is:-

class “Name”(“parent_class”):

statement 1

statement 2

Initially we use object as the parent class. In class we can declare multiple member functions. But the member functions must have a parameter a self. This is similar to the keyword this in C++.

class Add(object):

def sum(self, a, b):

return self.a+self.b

x = add(2,3)

print(“The sum is %d” %x.sum())

Output:-

The sum is 5

Inheritance:-

Inheritance can be done by replacing the name of the object class as a user defined class.

class A(object):

def a(self, aname):

self.aname = aname

def ret_a(self):

return self.aname

class B(A):

def b(self, bname):

self.bname = bname

def ret_b(self):

return self.bname

x = A(“Chandru”)

y = B(“Python”)

print(“Name in class A %s” % y.aname)

print(“Name in class B %s” % y.bname)

Output:-

Name in class A Chandru

Name in class B Python

Multiple classes:-

Multiple class can be declared by adding the parent class name in the paranthesis of the class.

class C(Object, A , B):

statement_1

statement_2

First try

SRM is conducting a hackathon. So they announced to submit their ideas with a team of 5 members. And so in this day, I spent to get some idea to implement in the hackathon. We chose domain as travelling and we submitted the abstract of our project to the website. The results will be submitted in the website soon.

Worst Weekend

This weekend I planed to enjoy a movie with my friends. On Thursday night I felt tired. On Friday, I became sick and that’s it my plan got broken into pieces. In the last three days, I didn’t do any proper work and I simply wasted my time. Even now I am feeling some loss of consciousness and feeling tired. It would be better if I got well before tomorrow.

Symposium

“Now you C me” my first competition which I was attended in my symposium. The competition is to debug the errors. But unfortunately I was not selected for the next round and I learnt something from that event to concentrate more on debugging.

Today I was feeling so tired as Started to play badminton in college. Day by day, I am becoming to lazy. To maintain my fitness I started Play badminton in college after the college hours. Playing after a long break made me so tired.

As I want to submit my mini project within this weekend, I was learning fully about the web development basics. At the end of the day, I am partially ready with the front end of the web development.