Commit e4fa8f9a by BellCodeEditor

auto save

parent 4ea37e4a
Showing with 35 additions and 5 deletions
# #功能:将0到99输出
# for i in range(100):#开始值是0 结束值100 步长 1 遵循的规则是取左不取右
# print(i)#输出i
# #功能:
# sum = 0 #初始值为0
# for i in range(1,101):#生成的数字是从1到100
# sum = sum + i #循环主体 赋值语句 将 sum + i 赋值给 sum 功能:求和 将1到100的数字加起来赋值给sum
# print(sum)#没有缩进不包含在循环中
#输出从0到100的偶数
# for i in range(0,101):#从0到100
# if i % 2 == 0: # % 取余 i % 2 == 0 如果一个数是2的倍数,那么这个数就是一个偶数0 2 4 6 8 10
# print(i)
#输出从0到100的奇数
for i in range(0,101):#从0到100
if i % 2 != 0: # % 取余 i % 2 != 0 如果一个数不是2的倍数,那么这个数就是一个奇数 1 3 5 7 9 。。。
print(i)
\ No newline at end of file
......@@ -3,14 +3,19 @@
每次移动都增加画笔移动的长度,并旋转91°,重复执行300次,查看效果
"""
import turtle
colors = ("red","orange","green","blue")
'''
元组和列表类似,同样拥有索引,索引起始值也是0 但是元组一经创建无法改变
'''
pen = turtle.Pen()
# 请创造师在下面接着创作
distance=1
#变量的初始化放到外边
pen.speed(0)
for i in range(300):
pen.forward(distance)
distance+=1
pen.right(121)
pen.pencolor(colors[i%4])
pen.fd(i)
pen.right(91)
# 隐藏画笔,保存画布
pen.hideturtle()
turtle.done()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment