Lesson 2: Loops draw shapes
이 페이지는 최신 브라우저(SharedArrayBuffer 지원)가 필요합니다. Chrome, Edge, Firefox 또는 Safari를 최신 버전으로 업데이트해 주세요.
English
Let a loop repeat
- The square had the same two lines four times.
- A
forloop repeats them for you.
Words for this lesson
| Word | Meaning |
|---|---|
| loop | code that runs again and again |
| repeat | do the same thing one more time |
| indent | the spaces at the start of a line inside the loop |
English
A square in three lines
import turtle
for i in range(4):
turtle.forward(100)
turtle.left(90)
- Both indented lines repeat 4 times.
난이도 1/5 · 100코인 + 오늘 첫 완료 시 작은 보너스 추가
Draw a square with sides of 120 steps. Use a for loop.
출력을 보려면 '실행'을 클릭하세요.
난이도 2/5 · 140코인 + 오늘 첫 완료 시 작은 보너스 추가
Draw a triangle with 3 equal sides of 150 steps. Use a loop. Hint: the turtle turns 120 degrees at each corner.
출력을 보려면 '실행'을 클릭하세요.