# Homework

AI悦创原创1v1java 1v1高中生Python辅导web 一对一数据结构一对一留学生辅导creanlutheran.org留学生作业辅导高中生Python辅导creanlutheran.org大约 2 分钟...约 474 字

1. Modify the condition in the outer loop so the turtle drawing has two “peaks” as shown, instead of one. No other change to the code needs to be made.
#   a114_nested_loops_4.py
import time
import turtle as trtl

painter = trtl.Turtle()
painter.penup()
painter.goto(-200, 0)
painter.pendown()

x = -200
y = 0
move_x = 1
move_y = 1
while x < 200:
while y < 100:
x = x + move_x
y = y + move_y
painter.goto(x, y)
move_y = -1

while y > 0:
x = x + move_x
y = y + move_y
painter.goto(x, y)
move_y = 1
# print("dd")
# time.sleep(10)
x = -200
y = 0
move_x = 1
move_y = -1  # 初始y方向改为向下
painter.penup()
painter.goto(-200, 0)
painter.pendown()
while x < 200:
while y > -100:  # 变为负值
x = x + move_x
y = y + move_y
print("上:", x, y)
painter.goto(x, y)
move_y = 1  # 现在向上移动

while y < 0:
x = x + move_x
y = y + move_y
print("下:", x, y)
painter.goto(x, y)
move_y = -1  # 恢复向下的方向

wn = trtl.Screen()
wn.mainloop()

Add Window Input using wn.textinput() and wn.numinput() screenshot code and window.

i = int(input("enter number:"))
while (i >= 0):
i = i + 1
print(i)

AI悦创·编程一对一

AI悦创·推出辅导班啦，包括「Python 语言辅导班、C++ 辅导班、java 辅导班、算法/数据结构辅导班、少儿编程、pygame 游戏开发、Web、Linux」，全部都是一对一教学：一对一辅导 + 一对一答疑 + 布置作业 + 项目实践等。当然，还有线下线上摄影课程、Photoshop、Premiere 一对一教学、QQ、微信在线，随时响应！微信：Jiabcdefh

C++ 信息奥赛题解，长期更新！长期招收一对一中小学信息奥赛集训，莆田、厦门地区有机会线下上门，其他地区线上。微信：Jiabcdefh

• 0
• 0
• 0
• 0
• 0
• 0

• 按正序
• 按倒序
• 按热度