# coding:utf-8
'''
------------------------------------------------------------------------
fruits=['apple','banana','pear','orange']
index=0
while index<len(fruits):
print(fruits[index])
index +=1
------------------------------------------------------------------------
for i in fruits:
print(1)
------------------------------------------------------------------------
n=[1,2,3,4,5,6]
for i in n:
print(i*6)
------------------------------------------------------------------------
heroes=['提莫队长','蛮族之王','战争女神','疾风剑豪']
for heroes in n:
print(i*4)
------------------------------------------------------------------------
#用列表存储cf神奇对象
------------------------------------------------------------------------
1.单词
------------------------------------------------------------------------
gun枪
price
------------------------------------------------------------------------
2.代码部分
------------------------------------------------------------------------
class Gun():
def __init__(self,name,type,price):
self.name=name
self.type=type
self.price=price
guns=[Gun('修罗','服务器','666'),Gun('激光','狙击枪','999'),Gun('青龙','突击步枪','888')]
for gun in guns:
print(gun.name+'是'+gun.type+'价格为:'+gun.price)
------------------------------------------------------------------------
class Gun():
def __init__(self,name,type,price):
self.name=name
self.type=type
self.price=price
guns=[Gun('修罗','服务器','666'),Gun('激光','狙击枪','999'),Gun('青龙','突击步枪','888')]
for gun in guns:
print(gun.name+'是'+gun.type+'价格为:'+gun.price)
-------------------------------------------------------------------
price=[23,43,18,77]
for i in price:
if i < 30:
print(i)
-------------------------------------------------------------------
'''
class Dog():
def __init__(self,name):
self.name=name
dogs=[Dog('二哈'),Dog('金毛'),Dog('泰迪')]
for dog in dogs:
print(dog.name)
发表回复