4.3数到20
a=list(range(1,21));
for cell in a:
print(cell);
4.5计算1000000的总和
a=list(range(1,1000001));
print(sum(a));
4.6奇数20以内
a=list(range(1,21,2));
for cell in a:
print(cell);
4.7 3的倍数
a=list(range(3,31,3));
for cell in a:
print(cell);
4.8 立方
a=list(range(1,11));
for cell in a:
print(cell**3);
4.9 立方解析
a=[cell**3 for cell in list(range(1,11))];
print(a);
4.11你的比萨和我的比萨
foods1 = ['pizza', 'falafel', 'carrot cake'];
friend_foods=foods1[:];
foods1.append("001");
friend_foods.append("002");
print(foods1);
print(friend_foods);
4.13自助餐厅
a=(1,2,3,4,5);
print(a);
a=(0,1,2,3,4);
print(a);