For_loops-554x368.png

For Loops & Nested Loops

8-10 yrs old

11-13 yrs old

14-18 yrs old

Art and Design

Computer Science

Learn more how to use For Loops in blocks, JavaScript and Python with MakeCode Coding Editor.

3
avatar Submitted By: Minecraft Education

October 12, 2020

Skills

  • Creativity
  • Critical Thinking

Learning Objectives

  • Learn how to use for loops (repeat blocks) in their code.
  • Learn how to nest loops inside each other.
  • Utilize the following National Core Arts Standards: Generate and conceptualize artistic ideas and work.
  • Utilize the following CSTA standards: 1A-AP-08, 1A-AP-09, 1A-AP-10, 1A-AP-11, 1A-AP-14, 1B-AP-10
  • Utilize the following ISTE standards: 5D

Guiding Ideas

These learning activities are designed to provide the learner with flexibility and choice in his/her learning.

The learner will be introduced to three tutorials that are at three levels of difficulty (Novice, Intermediate and Expert) which are followed by an educational activity where he/she can apply coding skills.

Within each tutorial, the learner will have the option of selecting a coding language (Blocks, JavaScript or Python).

The learner may choose a tutorial at his/her appropriate difficulty level and language OR choose to complete all tutorials and the educational activity. It will take approximately an hour to complete all the activities.

GUIDING QUESTIONS

  • What are things in our life that we repeat?

Eating, walking, breathing, etc

  • If I set a song on repeat, what will happen when it gets to the end of the song?

It will start over.

  • What are the reasons we might want to repeat parts of our code when working in Minecraft?

We want to do the same code in a different spot. 

Student Activities

TUTORIAL 1: SPAWN ANIMALS (Novice - 5 minutes)

Main objective: The learner will use events and for loops to spawn animals when specific events happen.

View the solution at: https://makecode.com/_5cKFx0Wad5Pq

TUTORIAL 2: FARM (Intermediate - 10 minutes)

Main objective: The learner will code the agent using for loops to plant carrots at the farm.

View the solution at: https://makecode.com/_fc9H0Y1v2WLR

TUTORIAL 3: HOUSE (Expert - 15 minutes)

Main objective: The learner will use build a house using for loops.

View the solution at: https://makecode.com/_Amid8E6u9VvJ

EDUCATIONAL APPLICATION (15 minutes)

Subject Area: Art

Main purpose of the activity:

  • Use loops in his/her code to create pixel art.
  • Experience various examples of pixel art in the land for additional ideas.
  • Use loops in their code to create his/her own pixel art.

The learner’s challenge is to use loops in the creation of pixel art.

Outcome of This Activity: The learner will have successfully created pixel art through using for loops and nested loops.

Possible Solution for this Activity:

View sample code online for a pixel art of a Minecraft creeper: https://makecode.com/_WP27LT7dw8cr 

Performance Expectations

Ask the learners about new skills that they have practiced during the activity to reinforce the concepts.

  • What does a for loop do?

It repeats the code for a specific number of times.

  • What is a nested loop?

It is a loop within a loop.

  • Why do you use loops?

Use loops to repeat a certain string of code. 

Skills

  • Creativity
  • Critical Thinking