python2day

for value in range(1,5):
print(value)
numbers=list(range(1,6))#生成列表
print(numbers)
squares=[]
for value in range(1,11):
square=value2
squares.append(square)
print(squares)
print(min(squares))
print(max(squares))
squares=[value
2 for value in range(1,11)]#列表解析
print(squares)
players=[‘charles’,‘martina’,‘michael’,‘florence’,‘eli’]
print(players[0:3])
print(players[2:])
for player in players[:3]:
print(player.title())
my_foods=[‘pizza’,‘falafel’,‘carrot cake’]
friend_foods=my_foods[:]#复制列表
print(“My favorite foods are:”)
print(my_foods)
#元组,修改元组被禁止
dimensions=(200,50)
print(dimensions[0])
for dimension in dimensions:
print(dimension)
cars=[‘bmw’,‘audi’,‘toyota’,‘subaru’]
for car in cars:
if car ==‘bmw’:
print(car.upper())
else:
print(car.title())
age_0=18
age_1=22
print(age_0>21 and age_1>21)
if ‘bmw’ in cars:
print(True)
else:
print(False)
age=18
if age<4:
price=0
elif age < 18:
price=5
elif age < 65:
price=10
elif age >=65:
price=15
print(‘you cost’+’ '+str(price))

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值