#2-8
print(5+3)
print(9-1)
print(2*4)
print(int(16/2))
#2-9
a=6
print("我最喜欢的数字"+":"+str(a))
#3-1姓名
s1=["xiaoming","xiaohong","xiaogang"]
print(s1)
#3-2问候语
print("Hello,"+str(s1[0]))
print("Hello,"+str(s1[1]))
print("Hello,"+str(s1[2]))
#3-3自己的列表
d=["car","bus","bicycle"]
print("I wold like to own a "+str(d[0]))
print("I wold like to own a "+str(d[1]))
print("I wold like to own a "+str(d[2]))
#数到20
num=list(range(1,21))
for x in num:
print(x)
#4-5 1-1000000的总和
n=list(range(1,1000001))
sum(n)
min(n)
max(n)
#4-6奇数
num=list(range(1,21,2))
foryinnum:
print(y)
#4-7 3的倍数
num=list(range(3,31))
z=[]
for i in num:
if i%3==0:
z.append(i)
print(z)
[3, 6, 9, 12, 15, 18, 21, 24, 27, 30]
#4-8立方
number=list(range(1,11))
numbers=[]
for x in umber:
x=x**3
numbers.append(x)
print(numbers)
[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
#4-9立方解析
num=[i**3 for in range(1,11)]
print(num)
[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
网友评论