Object Introduction.py

# Almost Every Thing in Python is Object
# An object is a member or an "instance" of a class
# i = 5, str = "Aubdur Rob Anik" all is object
# class define
class value:
a = 5
b = 10


first = value()
print("a = ", first.a)
print("b = ", first.b)


# built-in function __init__()
class information:
def __init__(person, name, roll):
person.name = name
person.roll = roll


c1 = information("Anik", 18101073)

print("Name :: ", c1.name)
print("Roll :: ", c1.roll)


# Class Function
class information:
def __init__(person, name, roll):
person.name = name
person.roll = roll

def function(person):
print(person.name, " roll is ", person.roll)


c1 = information("Anik", 18101073)
c1.function()


# Change Object Properties Values
class change:
x = 10
y = 20


c1 = change()
c1.x = 100
c1.y = 200

print("X = ", c1.x)
print("Y = ", c1.y)

# Delete A property
del c1.x
print("After Delete X is :: ", c1.x)
# if Again do this ---> del c1.x
# print("After Delete X is :: ", c1.x)
# It's Give Me Error cz c1.x permanently deleted

# Delete Object Property
class data :
def __init__(self, name, phone):
self.name = name
self.phone = phone

person = data("Anik", "01685946475")
print("Name :: ", person.name)
# del person.name
# print("Name :: ", person.name)
# It's Give Me Error cz person.name permanently deleted
#delete object
del person
#print(person)
#It's Give Me Error cz person object is Permanently Deleted

#pass Keyword
class boy :
pass

b1 = boy()
b1.name = "Anik"
b1.age = 14
b1.phone = "01685946475"

print("\nBoy Name :: ", b1.name)
print("Boy Age :: ", b1.age)
print("Boy Phone Number :: ", b1.phone)

Comments