Professional Documents
Culture Documents
Lab Prelim3
Lab Prelim3
Lab Prelim3
1. Source Code:
class Room:
def __init__(self, roomNo, roomType, roomArea):
self.roomno = roomNo
self.roomtype = roomType
self.roomarea = roomArea
def __int__(self):
return int(self.roomno)
def __str__(self):
return str(self.roomtype)
def __float__(self):
return float(self.rooamarea)
class setData:
def __init__(self, roomNo, roomType, roomArea, ACmachine):
self.acmachine = ACmachine
Room.__init__(self, roomNo, roomType, roomArea)
def __bool__(self):
return bool(self.acmachine)
def displayData(self):
print("The room no. is: ",self.roomno)
print("\nThe room type is: ",self.roomtype)
print("\nThe room area is: ",self.roomarea)
print("\nis the AC machine needed? ",self.acmachine)
class SimpleObject:
def __init__(self, object):
self.Object = object
def displayObject(self):
print(“The simple object that describes you is: “, self.Object)
object = “ A book because you cannot be judge only by your outside appearance”
o1 = simpleObject(object)
o1.displayObject()
3. Source Code:
class ValueReference:
def CallByValue(name):
print()
name = "John"
print("Inside Content: ", name)
print("Called By Value")
name = "Jules"
CallByValue(name)
print("Inside Content: ", name)
print()
def CallByReference(cars):
cars[0] = "Porsche"
print("Inside Content: ", cars)
print("Called By Reference")
cars = ["Honda","Ford","Lamborghini"]
print()
CallByReference(cars)
print("Outside Content: ",cars)
4. Source Code:
class square:
def __init__(this,sides):
this.sides = sides
def AreaOfSquare(this):
area = (this.sides*this.sides)*1
print("Side lenght: ",this.sides,"m")
print()
print("The area of a square that has a side lenght"
,this.sides,"is {} m^2".format(area))
print()