跳至主要內容
Homework
  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()

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

Question: 1

What kind of data structure is user_data in the following declaration?

user_data = ("TJ", 24, "artLover123")

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

Q1

Q2

Q3

Create a list of your favorite 4 movies. Print out the 0th element in the list. Now set the 0th element to be “Star Wars” and try printing it out again.

创建你最喜欢的4部电影的列表。打印列表中的第0个元素。现在将第0个元素设置为“星球大战”,然后再试着打印它。

# 创建一个包含4部电影的列表
favorite_movies = ["Movie1", "Movie2", "Movie3", "Movie4"]

# 打印列表中的第0个元素
print(favorite_movies[0])

# 将第0个元素设置为“星球大战”
favorite_movies[0] = "星球大战"

# 再次打印列表中的第0个元素
print(favorite_movies[0])

AI悦创原创...大约 11 分钟1v1java 1v1高中生Python辅导web 一对一数据结构一对一留学生辅导creanlutheran.org留学生作业辅导1v1java 1v1高中生Python辅导web 一对一数据结构一对一留学生辅导creanlutheran.org留学生作业辅导
5.10.1 Functions and Parameters Quiz

Question: 1

In the following code:「D」

size = 20
x = 100
y = 200
ball = Circle(size)
circle.set_position(x, y)

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

Question 1

Write a function that takes one parameter - a float which represents a temperature in Celsius - and returns a float which represents that temperature in Fahrenheit.

Then, write a function that does the opposite conversion.

Here are the formulas for temperature conversion:


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