for 语句
""">>> range(5)[0, 1, 2, 3, 4]>>> range(7)[0, 1, 2, 3, 4, 5, 6]>>> range(1,7)[1, 2, 3, 4, 5, 6]>>> range(2,7)[2, 3, 4, 5, 6]>>> range(11)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]>>> range(10)[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>>> range(1,11,2)[1, 3, 5, 7, 9]>>> range(2,11,2)[2, 4, 6, 8, 10]>>> range(2,11,3)[2, 5, 8]>>> range(11,2)[]
range():内置的python函数
range(stop):0~stop-1
range(start,stop):start~stop-1
range(start,stop,step):step:为步长
"""
#求1~100的和
sum = 0
for i in range(1,101):sum +=i #sum = sum + iprint(sum)
#求1~100的奇数之后
sum = 0
for i in range(1,101,2):sum += i
print(sum)
#求1~100的偶数之后
sum = 0
for i in range(2,101,2):sum += i
print(sum)
#用户输入一个数字,求该数的阶乘:3!=321
a = int(input('请输入一个数字:'))
sum = 1
for i in range(1,a):sum = sum * (i+1)
print(sum)