9 | Classes & Objects | Python for Complete Beginners

preview_player
Показать описание
# Creating Class
class MyClass1:
# attributes (data and functions)
pass

class MyClass:
a = 10

def func1(self):
print('Hello')

# Creating Objects
# to access attributes of a class
obj = MyClass()
print(obj.a)

# we can create multiple objects from a class
obj1 = MyClass()
obj2 = MyClass()

print(obj1.a)
print(obj2.a)

obj1.a = 20
obj2.a = 30

print(obj1.a)
print(obj2.a)

# Python is Object Oriented prog language
# Classes and Objects
# Class is a collection of data and functions
# Object is an instance of a class
# Class is a blueprint for an object

class MyClass2:
a = 10

def hello(self):
print('Hello World')

print(MyClass2.a)

class Calculate:

def add(self, num1, num2):
return num1 + num2

def multipy(self, num1, num2):
return num1 * num2

cal1 = Calculate()

▬▬▬▬▬▬

Every Like & Subscription gives me great motivation to keep working for you
You can support my mission for education by sharing this knowledge and helping as many people as you can

If my work has helped you, consider helping any animal near you, in any way you can

Never Stop Learning
Raghav Pal

▬▬▬
Рекомендации по теме
Комментарии
Автор

Sir, its my computer exam so can you make a video on just python objects.Our school principle has given us a private book named clouds for class 8 and its video is not anywhere and it is not on any website as well. Pls help it's a very important exam

SSWG-wv
Автор

Thanks Sir for everything you are doing. Im working as QA ENGINEER and your courses are helping me a lot. God bless you❤

ndemazizou
Автор

Hi Raghav sir,

I have 10 years of exp into testing, and worked on Selenium with java for 5 years and with python 1.5 years, due to my current project requirement they have moved me into functional completely, I want to upskill my automation skill again, so I wanted to know from where/what should I start learning - Cypress / RPA / performance test. which skills are demanding now in 2023. Please guide

shrutik
welcome to shbcf.ru