Python List Pop
Python List Pop
CLASSES EXAMPLE 01
class Employee:
def __init__(self,first,last,email):
self.first=first
self.last=last
self.email=first + '.'+ last +'@mrsaem.com'
emp1=Employee('SAEM','TARIQ','[email protected]')
emp2=Employee('ALI','MURTAZA','[email protected]')
print(emp1.email)
print(emp2.email)
________________________________________________________________
CLASSES EXAMPLE 02
class Human:
def __init__(self,n,o):
self.name=n
self.occupancy=o
def do_work(self):
if self.occupancy=="teacher":
print(self.name, " teaches Computer Science")
elif self.occupancy=="student":
print(self.name, "studies all the time")
def speaks(self):
print(self.name," says how are you")
Searching in Python
def search(list,n):
for i in range(len(list)):
if list[i]==n:
return True
return False
list=[3,5,6,7]
n=int(input("Enter the number"))
if search(list,n):
print("Found")
else:
print("Not Found")
__________________________________________________
Bubble Sort
# Bubble sort in python
# Sorts numbers in ascending order
str_input = input("Please enter numbers separated by spaces: ")
count = len(numbers)
print(numbers)