So, one way of doing this is to draw a square
and then turn a little bit to the right and then
draw another square. And then turn a little bit to the
right again and then draw another square. And keep doing that. Let's
build that. So, here's the piece of code that draws a
square. And after I've done that, what I want the turtle to
do is turn a little bit to the right. So, let
me add a piece of code that says brad.right, let's say by
ten degrees. Now, because I want these two statements to
happen over and over again, I will put them inside a loop. So let me do that. So
I'm going to add a for loop by saying for i in range, let's say this
loop runs four times. I'll add a colon and then put these two
things inside the loop. Let me save, and run, and see
what happens. Ah-ha, so here is the output. We've drawn two squares,
three squares and it should stop, there it is four squares. So all I have to
do now, is let the turtle keep going around the circle, which has 360 degrees.
So, this loop should run not four times, but 36
times instead. Let me save and
run that. All right. There it is, folks. A circle made out of squares. Now
I'm going to put some background music behind this
video and let you enjoy our final creation.
[MUSIC]
[MUSIC]
الطريقة الوحيدة لعمل ذلك هي رسم مربع
والاتجاه إلى اليمين قليلاً ثم
رسم مربع آخر. والاتجاه إلى اليمين
قليلاً مرة أخرى ثم رسم مربع آخر. مع الاستمرار في عمل ذلك. لنقم
بذلك. يظهر هنا جزء من التعليمة البرمجية التي ترسم
مربعًا. بعد القيام بذلك، أريد من turtle
الاتجاه قليلاً نحو اليمين. لذا دعني
أقوم بإضافة جزء من التعليمة البرمجية وهو brad.right، دعنا نقول
بعشر درجات. ولأنني أريد تكرار هاتين العبارتين
مرارًا وتكرارًا، سأضعهما داخل تكرار حلقي. إذًا، دعوني أقوم بهذا الأمر. سأقوم
بإضافة أربعة تكرارات حلقية من النوع for عن طريق كتابة for i in range، فلنفترض أن هذا
التكرار الحلقي يعمل أربع مرات. سأقوم بإضافة علامة النقطتين ثم أقوم بوضع هذين الشيئين
داخل التكرار الحلقي. دعوني أقوم بالحفظ والتشغيل ورؤية
،ما الذي يحدث. وها هي المخرجات. قمنا برسم مربعين
وثلاثة مربعات ويجب التوقف، وها هي أربعة مربعات. لذا كل ما يجب علي
.عمله الآن، هو جعل turtle تدور حول دائرة ذات 360 درجة
إذًا لا يجب أن يعمل هذا التكرار الحلقي أربع مرات، بل 36
مرة. سأقوم بحفظ
وتشغيل ذلك. حسنًا. هذا ما نتحدث عنه. رسم دائرة خارج المربعات. سأقوم
الآن بوضع بعض الموسيقى في خلفية
.الفيديو، ولتستمتع بإبداعنا النهائي
[MUSIC]
[MUSIC]
Bien, una manera de hacer esto es dibujar un cuadrado
y luego girar un poco a la derecha y después
dibujar otro cuadrado. Y luego girar un poco a la
derecha de nuevo y dibujar otro cuadrado. Y seguir haciendo esto. Vamos
a construirlo. Entonces, aquí tenemos este fragmento de código que dibuja un
cuadrado. Y después de que lo hayamos hecho, lo que queremos que turtle
haga es girar un poco a la derecha. Así que déjenme
agregar un fragmento de código que diga brad.right, digamos
diez grados. Y ya que quiero que estas dos órdenes
sucedan una y otra vez, las pondré dentro de un ciclo. Así que déjenme hacerlo. Entonces,
voy a agregar un ciclo for escribiendo for i in range, digamos que
este ciclo corra cuatro veces. Agregaré dos puntos y luego pondré estos dos
elementos dentro del ciclo. Déjenme guardarlo y ejecutarlo, y ver
qué sucede. Ajá, aquí tenemos el resultado. Hemos dibujado dos cuadrados,
tres cuadrados y se detendrá, eso es, cuatro cuadrados. Así que todo lo que tengo
que hacer ahora es dejar que turtle siga yendo alrededor del círculo, el cual tiene 360 grados.
Así que este ciclo deberá ejecutarse no cuatro veces,
sino 36 veces. Déjenme guardarlo y
ejecutarlo. Muy bien. Ahí lo tienen, chicos. Un círculo hecho de cuadrados. Ahora
voy a poner algo de música de fondo en este
video y los dejaré disfrutar nuestra creación final.
[MÚSICA]
[MÚSICA]
この図形を描くにはまず四角を描いて
次に同じ四角を少し右に傾けて描き
さらに右に傾けて同じ四角を描きます
これを繰り返すことで完成するのです
四角を描くコードはすでにあります
その次に必要なコードは
四角を少しずつ右に傾けるためのコードです
そこでbrad.rightというコードを追加します
傾ける角度は10度です
この2行を繰り返し行うよう
ループ文を書くことにします
for i in rangeというループ文です
4回繰り返すように設定してコロンを入力し
2行をループの中に入れます
保存して実行してみましょう
結果を見てみると四角を描いていきます
2個目も描き
3個目そして4個目の四角を描いて止まりました
今度は360度動くように設定を変えます
つまり4回ではなく36回続くはずです
それでは保存して実行してみましょう
四角から円が描き出されるのを見てください
この映像にはBGMが流れますので
図形ができるのを楽しんでください
Uma maneira de fazer isso é desenhar um quadrado,
virá-lo um pouco para a direita e
desenhar outro quadrado. E virá-lo um pouco para a
direita novamente, e desenhar outro quadrado. E assim por diante. Vamos
fazer isso. Este é o código que desenha um
quadrado. Isto feito, quero que o Turtle
vire o quadrado um pouco para a direita. Vou
adicionar um código que diz brad.right em
dez graus. Como quero que essas duas instruções
se repitam sem parar, vou colocá-las em um loop. Deixe-me fazer isso. Vou
adicionar um loop for dizendo "for i in range", digamos que esse
loop seja executado quatro vezes. Adicionarei dois-pontos e colocarei as duas instruções
dentro do loop. Vou salvar, executar e ver
o que acontece. Ah-ha, aqui está o resultado. Desenhamos dois quadrados,
três quadrados e o programa deve parar. Só preciso agora
deixar que o turtle continue fazendo um círculo, que tem 360 graus.
Este loop não deverá ser executado quatro vezes, mas 36
vezes. Vou salvar
e executar. Muito bem. Aqui está, pessoal. Um círculo feito de quadrados. Vou
inserir uma música ao fundo deste
vídeo e deixar que vocês desfrutem de nossa criação final.
[MUSIC]
[MUSIC]
那么 一种方法是画一个方形
接着向右转一点
再画另一个方形 然后向右转一点
再接着画另一个方形 然后继续这么做
让我们编写这个 这是画方形的代码
在我这么做之后 我想让乌龟做的
是向右转一点 那么
让我加上 brad.right 的代码
比如十度 现在 因为我想让这两个语句重复多次
我会把它们放在循环中 所以让我写这个 那么
我将添加一个 for 循环 先输入 for i in range
让循环运行四次 我会加一个冒号并将这两个
东西放在循环中 保存 接着运行 看看会
发生什么 啊哈 这里输出了 我们画了两个方形
三个方形接着它停了下来 这里有四个方形 所以我所要做的只是
让乌龟继续绕着圆圈跑 就是360度
所以 这个循环运行了不止四次 而是
36次 让我保存并运行
好的 完成了 大家 方形组成了一个圆 现在
我会在这个视频中放一些背景音乐
让你享受一下我们最终的作品
[音乐]
[音乐]