Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • CBSE
  • Class 10 Syllabus
  • Maths Notes Class 10
  • Science Notes Class 10
  • History Notes Class 10
  • Geography Notes Class 10
  • Political Science Notes Class 10
  • NCERT Soln. Class 10 Maths
  • RD Sharma Soln. Class 10
  • Math Formulas Class 10
Open In App
Next Article:
Ask(), Wait() and Answer() Block in Scratch Programming
Next article icon

What is Iteration in Scratch Programming?

Last Updated : 07 Aug, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

Scratch is a high-level visual programming language tool that interacts with users through diagrams and blocks that have the basics of a program inbuilt in it. Scratch is used to make interactive programs especially for kids using the block kind of interfaces so that they can easily learn languages and it is free to use. In this article, we will discuss the iteration block present in scratch. 

Scratch iteration block

Iteration is the concept that allows the repetition of commands or a set of lines. It is also known as a loop in the computer programming language. When the code executes(repeated) one time then this repetition is known as one iteration. The Iteration control block basically reduces the number of similar tasks to be performed by grouping the similar tasks in one block. In Scratch, the control block contains iteration tools as shown in the below image:

Now, let’s understand each iteration block in detail:

1. repeat (number n) block

It is a control block. This iteration block iterates the given set of commands ‘n’ number of times. The number n can be any positive integer. Here, n is the stopping condition of the iteration block. If the value of n is infinite then the loop runs forever, if the value n is a non-positive number then this loop will not run, and if the value of n is a decimal number then the number is round up. Let us understand the working of the repeat block with the help of a simple project:

Procedure:

Step 1: Click on event block and choose 1st control block denoting the start of the program(drag it to center).

Step 2: Click on add extension and choose pen block for drawing square.

Step 3: Place pen down block below the event block.

Step 4: Now drag the repeat block from the control block and place it down of pen down block. Change the number from 10 to 4.

Step 5: Click on motion block and drag move block and place it inside repeat block. Change the number from 10 to 50.

Step 6: Click on the turn block and place it below the move block inside the repeat block. Change the number from 15 to 90.

Step 7: Now run the program.

Below is the implementation of the procedure:

2. nested repeat block

A nested repeat block is created by placing a repeat block inside another repeat block. Here, two integer numbers will be used for the stopping condition. Let’s understand this by making a small project:

Procedure:

Step 1: Click on the event block and choose the 1st control block denoting the start of the program(drag it to center).

Step 2: Click on add extension and choose pen block for drawing a square.

Step 3: Place pen down block below the event block.

Step 4: Now drag repeat block from control block and place it down to the pen down block. Now change the number from 10 to 2.

Step 5: Now, again drag the repeat block from the control block and place it inside the first repeat block. Now, change the number from 10 to 2.

Step 6: Click on the motion block and drag the move block and place it inside the repeat block. Now, change the number from 10 to 50.

Step 7: Click on the turn block and place it below the move block inside the nested repeat block. Now, change the number from 15 to 90.

Step 8: Now run the program.

Below is the implementation of the procedure:

 3. forever block

It is a control block. This iteration block executes a particular set of commands infinitely. There is no stopping condition present in forever block. This kind of block is used to make patterns that are infinite in nature. For example, the square spiral. Let us understand the working of the forever block with the help of a simple project(i.e. square spiral):

Procedure:

Step 1: Click on event block and choose 1st control block denoting the start of the program(drag it to center).

Step 2: Click on add extension and choose pen block for drawing square spiral.

Step 3: Place pen down the block below the event block.

Step 4: Go to variable block and drag “set my variable to 80”.

Step 5: Drag the forever block from the control block and place it down of pen down block.

Step 6: Click on motion block and drag move block and place it inside the repeat block. Now change the number to “my variable”.

Step 7: Click on turn block(inside motion block) and place it below the move block inside repeat block. Now, change the number from 15 to 90.

Step 8: Go to variable block and drag “change my variable by 5”.

Step 9: Now run the program.

Below is the implementation of the procedure:

4. repeat until block

It is a control block. This iteration block executes a particular set of commands until a particular condition is not satisfied. The condition inserted in until is the stopping condition of the loop. This block is used when the stopping condition is known beforehand. Let us understand the working of the forever block with the help of a simple project. In this project, we draw a hexagon and the stopping condition of the hexagon would be 6.

Procedure:

Step 1: Click on the event block and choose the 1st control block denoting the start of the program(drag it to center).

Step 2: Click on add extension and choose pen block for drawing a square spiral.

Step 3: Place pen down block below the event block.

Step 4: Go to variable block and drag “set my variable to 0”.

Step 5: Drag repeat until block from control block and place it down of pen down the block.

Step 6: Go to operator block and drag O = O block and fill in the left blank with “my variable” and right blank with 6. Fix this in until blank.

Step 7: Click on motion block and drag move block and place it inside repeat until block. Now change the number to 50

Step 8: Click on turn block(inside motion block) and place it below the move block inside repeat until block. Now change the number from 15 to 60.

Step 9: Go to variable block and drag “change my variable by 1”.

Step 10: Now run the program.

Below is the implementation of the procedure:

5. nested repeat until block

A nested repeat until block is created by placing a repeat until block is placed inside another repeat until block. Here, two conditions will be used for stopping conditions. Let’s understand this by making a small project.

Procedure:

Step 1: Click on event block and choose 1st control block denoting start of the program(drag it to center).

Step 2: Click on add extension and choose pen block for drawing square.

Step 3: Place pen down block below the event block.

Step 4: Go to variable block and click on “make a variable”, name it a, drag “set a to 0”.

Step 5: Drag repeat until block from control block and insert it in another repeat until block.

Step 6: Go to operator block and drag O=O block and fill the left blank with “a” and right blank with 3. Fix this in until blank.

Step 7: Go to the variable block and drag “set my variable to 0” and place it inside repeat until block.

Step 8: Go to operator block and drag O=O block and fill left blank with “my variable” and right blank with 3. Fix this in the second repeat until blank.

Step 9: Click on motion block and drag move block and place it inside repeat block. Now, change the number from 10 to 50.

Step 10: Go to variable block and drag “change my variable by 1”.

Step 11: Click on the turn block and place it below the move block inside the repeat block. Now, change the number from 15 to 60.

Step 12: Outside the inner repeat block, go to the variable block and drag “change a by 1”.

Step 13: Now run the program.

Below is the implementation of the procedure:



Next Article
Ask(), Wait() and Answer() Block in Scratch Programming

P

pradiptamukherjee
Improve
Article Tags :
  • Class 10
  • School Learning
  • School Programming
  • Scratch-programming

Similar Reads

  • Introduction to Scratch Programming
    Scratch is an event-driven visual programming language developed by MIT. In Scratch, we can create our own interactive stories, games, and animations using building blocks. In this platform, we do not need to write code to perform operations, things are done just by drag and drop, just like visual b
    5 min read
  • Introduction to Scratch Programming
    Scratch is a block-based visual programming language that can be used to make interactive games and animations. It has a huge online community where you can share, discuss and view scratch programs. The objective behind the development of Scratch is to help children(mostly) to think creatively, work
    3 min read
  • Iteration Statements in Programming
    Iteration statements, commonly known as loops, are statements in programming used to execute part of code repeatedly based on condition or set of conditions. These constructs are important for performing repetitive tasks efficiently. In this article, we will discuss various types of iteration statem
    5 min read
  • What is Conditional Programming in Scratch?
    Scratch is a high-level visual programming language tool that interacts with users through diagrams and blocks that have the basics of a program inbuilt in it. Scratch is used to make interactive programs especially for kids using the block kind of interfaces so that they can easily learn languages
    5 min read
  • Ask(), Wait() and Answer() Block in Scratch Programming
    Scratch is a high level visual programming language tool that interacts with users through diagrams and blocks that have the basics of a program inbuilt in it. Scratch is used to make interactive programs especially for kids using the block kind of interfaces so that they can easily learn languages
    4 min read
  • What is Product Iteration?
    In today’s fast-moving market, focusing on customers is essential. Creating a product isn’t a one-time task, it is about continuously improving it. Product iteration means regularly updating the product based on customer feedback and data. This helps businesses make products that better meet custome
    9 min read
  • Script in Scratch Programming
    Scratch is an event-driven programming tool developed by the Lifelong Kindergarten group at MIT in the media lab to create your own games, visual programs, interactive stories using building blocks. To create a program in Scratch we do not need to write code to perform operations. In Scratch, the op
    4 min read
  • Basics of Scratch Programming
    Scratch is a programming language. Programming language is meant that a means of communicating with the computer, so as to give some instructions for it to perform. Programming in Scratch is very easy, including animation and games. It is a very useful tool for young kids or creators to learn and im
    6 min read
  • Variables in Scratch Programming
    Scratch is a high-level visual programming language tool that interacts with users through diagrams and blocks that have the basics of a program inbuilt in it. Scratch is used to make interactive programs especially for kids using the block kind of interfaces so that they can easily learn languages
    7 min read
  • What is Sprint, Iteration, and Increment?
    The article focuses on discussing the difference between Sprint, Iteration, and Increment. The following topics will be discussed here: What is Sprint?What is Iteration?What is Increment?Sprint vs Iteration vs Increment. Let's discuss these topics in detail. What is a Sprint? A sprint is a time-boxe
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences