In [1]:
class Employee:
# Define an attribute called name
name = "Ben"
def changeName (self):
# Change the value of the attribute within a method
Employee.name = "Mark"
employee = Employee()
print(employee.name)
employee.changeName()
print(employee.name)
In [13]:
class Emp:
name ="venkat"
jobtitle="Sales person"
sales=3
def achive (self):
if(self.sales>8):
print("Achived")
else:
print("fail")
In [14]:
emp1=Emp()
In [5]:
emp1.name
Out[5]:
In [7]:
emp1.jobtitle
Out[7]:
In [15]:
emp1.achive()
In [16]:
dir(Emp)
Out[16]:
In [18]:
type(Emp)
Out[18]:
In [19]:
type(emp1)
Out[19]:
In [20]:
l1=[1,2,3,4,5,]
In [21]:
l1
Out[21]:
In [22]:
type(l1)
Out[22]:
In [23]:
dir(l1)
Out[23]:
In [25]:
l1.pop()
Out[25]:
In [26]:
l1
Out[26]:
No comments:
Post a Comment