ONLINE SUMMER TRAINING Online Courses Free Tutorials 
 Placement Preparation 
Artificial Intelligence(AI) & Machine Learning(ML) Training in Jaipur
0 like 0 dislike
99 views
in Python Programming by Goeduhub's Expert (8.2k points)

Goeduhub's Online Courses @Udemy

For Indian Students- INR 570/- || For International Students- $12.99/-

S.No.

Course Name

Apply Coupon

1.

Tensorflow 2 & Keras:Deep Learning & Artificial Intelligence

Apply Coupon

2.

Computer Vision with OpenCV | Deep Learning CNN Projects

Apply Coupon

3.

Complete Machine Learning & Data Science with Python Apply Coupon

4.

Natural Language Processing-NLP with Deep Learning in Python Apply Coupon

5.

Computer Vision OpenCV Python | YOLO| Deep Learning in Colab Apply Coupon

6.

Complete Python Programming from scratch with Projects Apply Coupon

1 Answer

0 like 0 dislike
by Goeduhub's Expert (8.2k points)
 
Best answer

Python is an object oriented programming language.

  • Almost everything in Python is an object, with its properties and methods.
  • A Class is like an object constructor, or a blueprint for creating objects.

Class

Class is a set or category of things having some property or attribute in common and differentiated from others by kind, type, or quality.

To create a class, use the keyword class

Example-create a class named Firstclass , with a property named x:


class FirstClass:

    x=5

print(FirstClass)


<class '__main__.FirstClass'>

Object

Object is one of instances of the class which can perform the functionalities which are defined in the class.

Now we can use the class named FirstClass to create objects

Example- Create object named o1 and print the value of x. Here object o1 can access x value.


o1=FirstClass()

print(o1.x)


5

The __init__() function

  • We have gone through Classes and objects in their simplest form, and are not really useful in real life applications.

  • To understand the meaning of classes we have to understand the built-in __init__() function.

  • All classes have a function called __init__(), which is always executed when the class is being initiated.

  • Use the __init__() function to assign values to object properties, or other operations that are necessary to do when the object is being created:

Example-Create a class named Student and use the init() function to assign values for name and age. 


class Student:

    def __init__(self, name, age):

        self.name = name

        self.age = age

p1 = Student("Smith", 16)

print(p1.name)

print(p1.age) 


Smith 16

Our Mentors(For AI-ML)


Sharda Godara Chaudhary

Mrs. Sharda Godara Chaudhary

An alumna of MNIT-Jaipur and ACCENTURE, Pune

NISHA (IIT BHU)

Ms. Nisha

An alumna of IIT-BHU

Related questions

1 like 0 dislike
6 answers 736 views
asked Oct 30, 2019 in Python Programming by Goeduhub Goeduhub's Expert (8.2k points)
1 like 0 dislike
1 answer 93 views
1 like 0 dislike
1 answer 55 views
asked Oct 11, 2019 in Python Programming by Goeduhub Goeduhub's Expert (8.2k points)
0 like 0 dislike
5 answers 1k views
asked Oct 11, 2019 in Python Programming by Goeduhub Goeduhub's Expert (8.2k points)
0 like 0 dislike
1 answer 79 views

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy || Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 
...