The Wayback Machine - https://web.archive.org/web/20241123150249/https://www.geeksforgeeks.org/basics-of-scratch-programming/
Open In App

Basics of Scratch Programming

Last Updated : 18 Nov, 2022
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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 implement coding logic. It was developed by MIT’s Media Lab and it is free and can be used online on its, website, or it can be downloaded to use offline. It is available for operating systems like Windows, iOS, ChromeOS, Android 6.0+, etc. In this article, we will discuss the basics of Scratch.

Script

In Scratch, a script is a set of instructions that are used to create a Scratch program. Or we can say that it is a stack of blocks that are connected with each other and perform the specified tasks. Scripts are used to interact with sprites and tell them what to do or say. We can create a script in the script area. Here, we drag the blocks from the block palette and assemble them to create scripts. 

Script

Sprite

There are objects and characters that could be added to a program to perform actions based on code written in scripts in a project using blocks, these objects and characters are known as Sprite. You can add a prebuilt sprite or create a new sprite as per your requirement. You can find the option to add the sprite in the right bottom corner, second menu from the right corner. There are many free sprites already available in the store, you can choose any of them or can paint a new sprite, or upload any other sprite. Below are some of the preloaded sprites from the scratch,

 Scratch-Sprite

Some Sprites of Scratch 

Tempo

If you want to attach any instrumental blocks or beats to your scratch project then you need to determine how fast your note has to play. Whether you want to play the same beat for 60 seconds you want to play 3-4 beats for some time period. This control of the speed of instrumental beats in Scratch is known as Tempo.

Tempo

Events

Events in Computer Science refer to the trigger, which makes anything happen when any button is clicked or any action has happened. In Scratch, events are represented by Yellow color blocks, which include when the flag is clicked, when the sprite is clicked, when the key is pressed, etc.

Events

Backdrops

When you program something in Scratch, you have full freedom to use and change the background, before or during the program. These background effects are known as Backdrops.

Backdrops

Coding Blocks

Coding blocks are some pre-defined or pre-written blocks of code that make writing statements of code very simple in Scratch. You can use any coding blocks by simply dragging and dropping as per your requirements. You may also create your custom block if you want. Below are a few of the coding blocks explained in brief. Besides, there are various other coding blocks available, and also you and create your blocks too. 

  • Motion: These are used to move a sprite back and forth or in any direction or rotate them.
  • Looks: These are used to change the look of the sprite or replace them with some other sprite of the same category.
  • Sounds: Tempo or Sounds are used to control the sound flow in the program.
  • Events: Events handle trigger calls.
  • Controls: Conditional operators and loops are all in this category.
  • Sensing: Sensing controls how to react whenever the mouse pointer hits the playground and/or touches the sprite or by the motion of the mouse.
  • Operators: These are for the control and flow of arithmetic operations in the program.
  • Variables: You can declare the variables, in your program using these blocks.
  • My Blocks: You can create your custom blocks from here. 

Coding-blocks

Loops 

Loops in Scratch or any programming language help you execute the same line of code with or without different values for ‘n’ a number of times. You can either set the number of times or set a condition to end the loop. Scratch supports the following loops:

  • repeat: This block is used to iterate the given set of instructions ‘n’ a number of times. Here, the value of n is a positive number.
  • forever: This block is used to execute the given set of instructions infinitely.
  • repeat until: This block is used to iterate the given set of instructions until the given condition is not satisfied. 

Loops

Conditions

Conditions in Scratch are implemented using Control blocks. You can use control blocks to check for a condition and based on if the condition is true or false, the required code/script can be executed. Two of the most popular control blocks are:

  • if-then: In this block, if the given condition is true the code/script present inside this block will execute. Otherwise, the code/script present inside this block will be ignored.
  • if-then-else: In this block, if the given condition is true the code/script present inside this block will execute. Otherwise, the code/script present inside the else block will execute.

Projects

Any creation in Scratch such as code for a game, story, or animation is termed as a project in Scratch. You can create a project by using the Scratch editor. Once a project has been created it can be shared with other Scratch programmers (called Scratchers). As of Sep, 22 there are over 100 million shared projects in Scratch. 

Any scratches can use the code of a shared project and create another project through it. This process is called “Remixing”. As part of the community guidelines, you should acknowledge the creator of the original project whenever you are remixing their code. 

Scratch Project Example

Below is the implementation of a simple program:

Here we have made a girl walk along the beachside. She will walk a few steps and then say “Hello”. Let’s see how we have implemented this.

  1. First, you have to select a suitable backdrop for your project. Here I have used the “Beach Malibu” backdrop.
  2. Select the sprite you want to work with. Here I have used the “Avery walking” sprite.
  3. Follow the following script:

Scratch-project-example

Working of Code

  • The first event is when the flag is clicked, it is for starting the program.
  • The second block of code makes the sprite located in the initial position that is x is -164 and y is -69.
  • Then we placed a loop to repeat moving by changing the costume 20 times.
  • After completing the loop the sprite will say hello for one second.

Output:

Output

Scratch program running demo 



Previous Article
Next Article

Similar Reads

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 and it is free to use. In this article, we will le
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 collaboratively and solve problems systematically
3 min read
What is Iteration 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 and it is free to use. In this article, we will di
7 min read
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 basic. It is the best platform to start basic progr
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 and it is free to use. In scratch, ask() and wait,
4 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 operation is performed just by drag and drop, simila
4 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 and it is free to use. In this article, we will di
7 min read
Learn Basics of Programming For FREE - 2 Day Workshop For Students!
The registration/enrollment for the First Step to Coding - Demo Classes has currently been closed. All the young ones or school students can visit this link to explore various enriching beginner-level courses. To all the students out there, don't you young ones want to learn a skill that can make you able to build a fantastic mobile game or your ow
5 min read
Top 30 Scratch Projects in 2024
Scratch is a free programming language developed by MIT where students can create their own interactive stories, games, and animations. Scratch provides a child-friendly platform where kids can learn coding through interactive, fun game projects. It makes programming approachable with its easy-to-use interface and engaging colorful graphics. Here,
8 min read
Basics Concepts of Thermodynamics
Thermodynamics is concerned with the ideas of heat and temperature, as well as the exchange of heat and other forms of energy. The branch of science that is known as thermodynamics is related to the study of various kinds of energy and its interconversion. The behaviour of these quantities is governed by three main laws of thermodynamics, which pro
12 min read
Basics of Input and Output in Windows PowerShell
Windows PowerShell is a command-line and scripting language designed for system administration. It helps IT professionals, to control and automate the administration of the Windows Operating System and Windows Server Environment. There are cmdlet for console input and output using PowerShell. Example 1: Showing the Output to console Function to pri
2 min read
Basics of Algebra
Algebra is the branch of Math which uses alphabetical letters to find unknown numbers. These letters are also called variables. The values are known in the given expression such as numbers are called constants. When we speak about its basics, it covers the general algebraic expressions, formulas and identities, which are used to solve many mathemat
5 min read
Object Oriented Programming in Python | Set 2 (Data Hiding and Object Printing)
Prerequisite: Object-Oriented Programming in Python | Set 1 (Class, Object and Members) Data hiding In Python, we use double underscore (Or __) before the attributes name and those attributes will not be directly visible outside. Python Code class MyClass: # Hidden member of MyClass __hiddenVariable = 0 # A member method that changes # __hiddenVari
3 min read
Why is programming important for first year or school students?
Although computer programming was once seen as a skill reserved for geeks and computer nerds, it’s now regarded as an essential ability for 21st century learners and is becoming a key component of many curriculums, even in primary schools. And as it is becoming essential to learning programming basics in school itself, you need to be ahead of those
6 min read
CBSE Class 11 | Concepts of Programming Methodology
Inrtoduction : Programming methodology is the process of designing, writing, testing, and maintaining computer programs. It encompasses various concepts and techniques that programmers use to develop software applications efficiently and effectively. Programming is all about solving a particular problem through computerized codes. Whether it be a p
15 min read
Concept of Comments in Computer Programming
Comments are text notes added to the program to provide explanatory information about the source code. They are used in a programming language to document the program and remind programmers of what tricky things they just did with the code and also helps the later generation for understanding and maintenance of code. The compiler considers these as
4 min read
Modular Approach in Programming
Modular programming is the process of subdividing a computer program into separate sub-programs. A module is a separate software component. It can often be used in a variety of applications and functions with other components of the system. Some programs might have thousands or millions of lines and to manage such programs it becomes quite difficul
3 min read
Programming Language Generations
A computer is a digital machine. It can only understand electric signals either ON or OFF or 1 or 0. But how do we communicate with this digital machine? Just like there are multiple languages we communicate with each other (e.g., English, Hindi, Tamil, Gujarati, etc.). But computers cannot understand our languages. We can interact with the compute
6 min read
Introduction of Object Oriented Programming
As the name suggests, Object-Oriented Programming or OOPs refers to languages that use objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism, etc in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of
6 min read
Class 12 RD Sharma Solutions - Chapter 30 Linear Programming - Exercise 30.5
Question 1. Two godowns A and B have gain capacity of 100 quintals and 50 quintals respectively. They supply to 3 ration shops D, E and F whose requirements are 60, 50 and 40 quintals respectively. The cost of transportation per quintal from the godowns to the shops are given in the following table:Transportation cost per quintal (in Rs)From/ To A
7 min read
Different Ways to Setting Up Environment For C++ Programming in Mac
Xcode is an IDE developed by Apple themselves to develop apps for macOS and iOS or all other Operating Systems that Apple develops. It also has support for C/C++ built-in. Here, finding a C++ IDE for a macOS system is quite easy. To run a program in C++ in Mac we have to install Xcode or command-line tools for Xcode. Ways: Hence, there are two opti
3 min read
What is the Difference between Interactive and Script Mode in Python Programming?
Python is a programming language that lets you work quickly and integrate systems more efficiently. It is a widely-used general-purpose, high-level programming language. It was designed with an emphasis on code readability, and its syntax allows programmers to express their concepts in fewer lines of code. In the Python programming language, there
7 min read
5 Best Programming Languages For Newbies
Learning a first programming language is always special for everyone. We get attached to it and it sticks with us forever. You might have been 10 years old, 12 years old, 15 years old, or whatever your age was, we are sure it was definitely special for you and it will be in the future as well. After all, you put in so much effort and you experience
6 min read
The "Hello World" To Programming
If you have suddenly got interested to get into programming, maybe because your school finally started teaching a programming language (that too most probably during the last years of school life) and/or you surf online to find the cool stuff that people do with programming or you are fascinated by the knowledge and skill that experts have. Either
4 min read
Types of Linear Programming Problems
Linear programming is a mathematical technique for optimizing operations under a given set of constraints. The basic goal of linear programming is to maximize or minimize the total numerical value. It is regarded as one of the most essential strategies for determining optimum resource utilization. Linear programming challenges include a variety of
8 min read
Class 12 NCERT Solutions- Mathematics Part ii – Chapter 12– LINEAR PROGRAMMING Exercise 12.1
Solve the following Linear Programming Problems graphicallyQuestion 1. Maximise Z = 3x + 4y subject to the constraints : x + y ≤ 4, x ≥ 0, y ≥ 0.Solution: Maximise Z = 3x + 4y subject to the constraints: x + y ≤ 4 x ≥ 0 y ≥ 0Constraint y ≥ 0 & x ≥ 0 ⇒ Feasible region in the 1st quadrant. Table of values for line x + y = 4 corresponding to const
10 min read
Linear Programming
Linear programming is a mathematical concept that is used to find the optimal solution of the linear function. This method uses simple assumptions for optimizing the given function. Linear Programming has a huge real-world application and it is used to solve various types of problems. The term "linear programming" consists of two words linear and p
15+ min read
Graphical Solution of Linear Programming Problems
Linear programming is the simplest way of optimizing a problem. Through this method, we can formulate a real-world problem into a mathematical model. There are various methods for solving Linear Programming Problems and one of the easiest and most important methods for solving LPP is the graphical method. In Graphical Solution of Linear Programming
13 min read
School Programming
Recent Articles The page is designed for beginners in programming language, especially school students. It has following sections. Introduction to Programming LanguagesLearning a Programming LanguageProgramming Problems and SolutionsPractice ProblemsRecent School Coding ArticlesRecent School Coding Practice Problems Multiple Choice Questions - C, C
7 min read
Class 12 RD Sharma Solutions- Chapter 30 Linear Programming - Exercise 30.1 | Set 2
Question 11. Two tailors A and B earn Rs 150 and Rs 200 per day respectively. A can stitch 6 shirts and 4 pants per day while B can stitch shirts and 4 pants per day. Form a linear programming problem to minimize the labour cost to produce at least 60 shirts and 32 pants.Answer:  Taylor A Taylor BLimitVariablex+y Shirts6x+10y>=60Pants4x+4y>=3
11 min read
three90RightbarBannerImg