|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
green_alien_list =[]
red_alien_list =[]
yellow_alien_list=[]
number=0
c=1
class alien():
def __init__(self, name, colour, love_food, age, height):
self.name=name
self.colour=colour
self.love_food=love_food
self.age=age
self.height=height
def description(self):
a="Hello "+self.name+"!"+"I know you love food is"+self.love_food+"."
return a
def info(self):
inf={
'name': (self.name ).title(),
'colour': self.colour,
'age': self.age,
'love food': self.love_food,
'height': self.height
}
return inf
while c<100:
name = input("Please input alien's name: ")
if name=='stop':
break
colour = input("Please input alien's colour: ")
if colour=='stop':
break
love_food = input("Please input alien's love food: ")
if love_food =='stop':
break
age = input("Please input alien's age: ")
if age=='stop':
break
height = input("Please input alien's height: ")
if height=='stop':
break
b= name.title()+' '+colour+' '+love_food+' '+str(age)+' '+str(height)
d=alien(name,colour,love_food,age,height)
if colour == "green":
number+=5
green_alien_list.append(b)
elif colour == "red":
number+=15
red_alien_list.append(b)
elif colour == "yellow":
number+=10
yellow_alien_list.append(b)
c+=1
print(green_alien_list)
print(red_alien_list)
print(yellow_alien_list)
print("Your final score: "+str(number))
print(d.info())
|
|