0% found this document useful (0 votes)
17 views1 page

Class

In Python, a class serves as a blueprint for creating objects, encapsulating properties (attributes) and actions (methods). Classes are defined using the 'class' keyword, and can include instance, static, and local variables, as well as various types of methods. Documentation strings can describe the class and can be accessed using 'print(classname.__doc__)' or 'help(classname)'.

Uploaded by

Amol Adhangale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

Class

In Python, a class serves as a blueprint for creating objects, encapsulating properties (attributes) and actions (methods). Classes are defined using the 'class' keyword, and can include instance, static, and local variables, as well as various types of methods. Documentation strings can describe the class and can be accessed using 'print(classname.__doc__)' or 'help(classname)'.

Uploaded by

Amol Adhangale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Python's Object Oriented Programming (OOPs)

What is Class:
In Python every thing is an object. To create objects we required some Model or
Plan or Blue
print, which is nothing but class.
We can write a class to represent properties (attributes) and actions (behaviour)
of object.
Properties can be represented by variables
Actions can be represented by Methods.
Hence class contains both variables and methods.
How to Define a class?
We can define a class by using class keyword.
Syntax:
class className:
''' documenttation string '''
variables:instance variables,static and local variables
methods: instance methods,static methods,class methods
Documentation string represents description of the class. Within the class doc
string is always
optional. We can get doc string by using the following 2 ways.
1. print(classname.__doc__)
2. help(classname)
Example:
1) class Student:
2) ''''' This is student class with required data'''
3) print(Student.__doc__)
4) help(Student)
Example for class:
1) class Student:
2) def __init__(self):
3) [Link]='amol'
4) [Link]=40
5) [Link]=80
6)
7) def talk(self):
8) print("Hello I am :",[Link])
9) print("My Age is:",[Link])
10)print("My Marks are:",[Link])

You might also like