class employee:
def __init__(self,fname,lname,id1,salary):
self.fname = fname
self.lname = lname
self.id1 = id1
self.salary = salary
if __name__ == '__main__':
emp1 = employee("Michael","Vine",123,50000.00)
print "\n First name: " + emp1.fname + "\n"
print "Last name: " + emp1.lname + "\n"
print "Employee ID: " + str(emp1.id1) + "\n"
print "Salary: " + str(emp1.salary) + "\n"
class employee:
def __init__(self,fname,lname,id1,salary):
self.fname = fname
self.lname = lname
self.id1 = id1
self.salary = salary
if __name__ == '__main__':
emp1 = employee("Michael","Vine",123,50000.00)
print "\n First name: " + emp1.fname + "\n"
print "Last name: " + emp1.lname + "\n"
print "Employee ID: " + str(emp1.id1) + "\n"
print "Salary: " + str(emp1.salary) + "\n"
class scores:
def __init__(self,name,score):
self.name = name
self.score = score
if __name__ == '__main__':
highScores = []
highScores.append(scores("Hunter",40768))
highScores.append(scores("Kenya",38568))
highScores.append(scores("Apollo",35985))
for x in range(3):
print "\n" + highScores[x].name + "\t" + str(highScores[x].score) + "\n"
class employee:
def __init__(self,id1,name,salary):
self.id1 = id1
self.name = name
self.salary = salary
def processEmp(emp1):
emp1.id1 = 123
emp1.name = "Sheila"
emp1.salary = 65000.00
if __name__ == '__main__':
emp1 = employee(0,0,0)
processEmp(emp1)
print "\n Id : " + str(emp1.id1) + "\n"
print "Name : " + emp1.name + "\n"
print "Salary : " + str(emp1.salary) + "\n"
class player:
def __init__(self,name,score):
self.name = name
self.score = score
if __name__ == '__main__':
aPlayer = player(0,0)
ptrPlayer = id(aPlayer)
aPlayer.name = "Pinball Wizard"
aPlayer.score = 1000000.00
print "\nPlayer : " + aPlayer.name + "\n"
print "Score : " + str(aPlayer.score)
class employee:
def __init__(self,id1,name,salary):
self.id1 = id1
self.name = name
self.salary = salary
def processEmp(emp1):
emp1.id1 = 123
emp1.name = "Sheila"
emp1.salary = 65000.00
if __name__ == '__main__':
emp1 = employee(0,0,0)
ptrEmp = id(emp1)
processEmp(emp1)
print "\nId : " + str(emp1.id1) + "\n"
print "Name : " + emp1.name + "\n"
print "Salary : " + str(emp1.salary) + "\n"
class employee:
def __init__(self,id1,name,salary):
self.id1 = id1
self.name = name
self.salary = salary
def processEmp(emp1 = []):
emp1.append(employee(123,"Sheila",65000.00))
emp1.append(employee(234,"Hunter",28000.00))
emp1.append(employee(456,"Kenya",48000.00))
return emp1
if __name__ == '__main__':
emp1 = []
emp1 = employee(0,0,0)
emp1 = processEmp(emp1 = [])
for x in range(3):
print "\nId : " + str(emp1[x].id1) + "\n"
print "Name : " + emp1[x].name + "\n"
print "Salary : " + str(emp1[x].salary)
class phonebook:
def __init__(self,name,number,address):
self.name = name
self.number = number
self.address = address
class magazine:
def __init__(self,name,author,isbn):
self.name = name
self.author = author
self.isbn = isbn
if __name__ == '__main__':
aBook = phonebook("John",123,"John Smith")
aMagazine = magazine("C Programming","Michael Vine",1-59863-480-1)
print "\nUnion Details\n"
print "Address for aBook.name: " + str(id(aBook.name)) + "\n"
print "Address for aBook.number: ", str(id(aBook.number)) + "\n"
print "Address for aBook.address: ", str(id(aBook.address)) + "\n"
print "\nStructure Details\n"
print "Address for aMagazine.name: ", str(id(aMagazine.name)) + "\n"
print "Address for aMagazine.author: ", str(id(aMagazine.author)) + "\n"
print "Address for aMagazine.isbn: ", str(id(aMagazine.isbn)) + "\n"
x = 12
y = 5
print "\nWithout Type-Casting\n"
print "12 \\ 5 = " + str(x/y) + "\n"
print "\nWith Type-Casting\n"
print "12 \\ 5 = " + str(float(x)/float(y)) + "\n"
number = 86
letter = 'M'
print "\n86 type-casted to char is: " + chr(number) + "\n"
print "\n'M' type-casted to int is: " + str(ord(letter)) + "\n "
# This program is not possible in python.