Saltar navegación

ACTIVIDADE 5 LOGO. BUCLES

¿Recordas cando fixeches o programa dos polígonos? As instrucións en todos eles repítense, polo tanto podemos simplificar o programa empregando os BUCLES.

¿Que comando debo empregar?

repeat nº de veces [ as instrucións]

Exemplo:

repeat 8 [ fd 50 rt 45]

Bucle
Bucle (CC BY-SA)

Podemos executar un bucle dentro doutro. Se facemos isto estamos realizando o que se chama BUCLES ANIDADOS

¿Que comando debo empregar?

repeat nº de veces [ repeat [instrucións] instrución]

Exemplo:

repeat 36 [repeat 4 [fd 50 rt 90] rt 10]

Bucle anidado
Bucle anidado (CC BY-SA)

¿Practicamos?

Aquí tes algúns bucles, fainos e indica que figura debuxa:

  1. repeat 8 [ fd 50 rt 45]
  2. repeat 6 [ fd 50 rt 60]
  3. repeat 3 [ fd 50 rt 120]
  4. repeat 3 [ fd 100 rt 120]
  5. repeat 5 [ fd 100 rt 72]
  6. repeat 36 [ fd 10 rt 10]
  7. repeat 4 [ fd 100 rt 90]
  8. repeat 20 [ fd 50 ]

Agora tes algún bucle anidado para que practiques:

  1. repeat 8 [ repeat 4 [fd 20 rt 90] fd 25]
  2. repeat 36 [ repeat 4 [fd 120 rt 90] rt 10]
  3. repeat 36 [ repeat 4 [fd 80 rt 90] rt 10]
  4. repeat 36 [ repeat 4 [fd 60 rt 90] rt 10]