programming like c, c++, java,python learn in free

Saturday, April 18, 2020

what is class?(python) with example

  1.  In Python every thing is an object. To create objects we required some Model or Plan
  2. or Blue print, which is nothing but class.
  3.  We can write a class to represent properties (attributes) and actions (behaviour) of object.
  4.  Properties can be represented by variables Actions can be represented by Methods.
  5. 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)
Share:

0 comments:

Post a Comment

Unordered List

recentposts1
Powered by Blogger.

Text Widget

Featured Post

C programming Question and Answer Day-15

71. Program to check Niven number (Harshad number). #include<stdio.h> #include<conio.h> void main() {     int n, d, a, su...

Search This Blog

recent comments

recentcomments

Labels

[slideshow][technology]

vertical posts

[verticalposts][technology]

business

[business][grids]

ad space

ads 600

vehicles

[cars][stack]
[verticalposts][food]

our facebook page

about us

logo

Jupiter is a magazine responsive Blogger template. It has everything you need to make your blog stand out. This template is fully customizable and very flexible and we believe you will love it as much as we do.

Slide show

[people][slideshow]

health

[health][btop]

recent posts

recentposts1

Subscribe Us

random posts

randomposts2

Blog Archive

Recent Posts

top ads

Unordered List

recent

Pages

Theme Support

[socialcounter] [facebook][#][215K] [twitter][#][115K] [youtube][#][215,635] [rss][#][23M] [linkedin][#][21.5K] [instagram][#][600,300]