a = student("hydya",10164,30,150)
b = student("ameba",10165,35,160)
c = student("tic",10166,40,170)
d = student("toc",10167,50,160)
data_student = [a,b,c,d]
display_array(data_student)
def display_array(data):
count = 0
while(count<len(data)):
data[count].show_data()
count += 1
class student:
def __init__(self,name,iD,weight,height):
self.name = name
self.iD = iD
self.weight = weight
self.height = height
def show_data(self):
print(">>>>>>>>>><<<<<<<<<<<<")
print("Student name ",self.name)
print(" id is ",self.iD)
print("weight is ",self.weight)
print("height is ",self.height)
setup()
ผลลัพธ์
>>>>>>>>>><<<<<<<<<<<<Student name hydyaid is 10164weight is 30height is 150>>>>>>>>>><<<<<<<<<<<<Student name amebaid is 10165weight is 35height is 160>>>>>>>>>><<<<<<<<<<<<Student name ticid is 10166weight is 40height is 170>>>>>>>>>><<<<<<<<<<<<Student name tocid is 10167weight is 50height is 160
ไม่มีความคิดเห็น:
แสดงความคิดเห็น