G4_Coding_AY25

Page 1


Tekie

Computer Science Scratch 3.0 II

Acknowledgements

Academic Authors: Jatinder Kaur, Ayushi Jain, Anuj Gupta, Simran Singh

Creative Directors: Bhavna Tripathi, Mangal Singh Rana, Satish

Book Production: Rakesh Kumar Singh, Sakshi Gupta

Project Lead: Jatinder Kaur

VP, Learning: Abhishek Bhatnagar

All products and brand names used in this book are trademarks, registered trademarks or trade names of their respective owners.

© Uolo EdTech Private Limited

First published 2023

Second published 2024

Third published 2025

This book is sold subject to the condition that it shall not by way of trade or otherwise, be lent, resold, hired out, or otherwise circulated without the publisher’s prior written consent in any form of binding or cover other than that in which it is published and without a similar condition including this condition being imposed on the subsequent purchaser and without limiting the rights under copyright reserved above, no part of this publication may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without the prior written permission of both the copyright owner and the above-mentioned publisher of this book.

Book Title: Tekie Computer Science Scratch 3.0 II

ISBN: 978-81-979297-5-5

Published by Uolo EdTech Private Limited

Corporate Office Address:

85, Sector 44, Gurugram, Haryana 122003

CIN: U74999DL2017PTC322986

Illustrations and images: www.shutterstock.com, www.stock.adobe.com and www.freepik.com

All suggested use of the internet should be under adult supervision.

Preface

Standing at the forefront of the digital and AI revolution, the importance of coding and computational skills has reached unprecedented heights. In today’s professional landscape, whether it is in the fields of medicine, space exploration, education, science, or business, no sector remains untouched by this transformative wave. To thrive in the 21st century, basic computer literacy is no longer sufficient. Learners must evolve into “digital natives” who can fluently read, write, and communicate in the languages that machines and AI comprehend. Recognising this imperative, the National Education Policy of 2020 (NEP 2020) has strongly recommended the integration of coding skills, computational thinking, critical analysis, and problem-solving abilities into the curriculum. Moreover, forward-looking subjects like AI, Data Science, Computer Applications, and IT have been introduced as elective subjects from grade 9 onwards. It would not be surprising if further transformative measures are taken even at the elementary education level.

Inspired by these insights, Uolo has introduced an innovative 360-degree program for a codingfocused computer science curriculum, known as Tekie, spanning grades 1 to 8. The program provides an experiential learning approach, going beyond theoretical knowledge. It not only covers theoretical aspects of computer science and coding, but includes hands-on activities and technology-based projects that enable students to experience computer science first hand. The program includes chapters that provide a deeper immersion in computer science that both learners and teachers may find interesting.

This coding book is a part of the larger Tekie program that also includes a main computer science textbook, covering the basics of computing, the latest technologies, and essential computer tools.

In addition to the textbooks, we provide a digital platform where students can actively engage in practical activities and hands-on learning projects. This platform is designed to enhance the learning process by allowing students to experiment and apply their knowledge in a real-world context.

We have meticulously aligned our activities with the guidelines of the National Education Policy (NEP) 2020, which emphasises a holistic approach to learning. This approach is aimed at developing critical thinking, logical reasoning, and practical skills among students. By integrating these elements into our coding program, we aim to prepare students for the future, equipping them with the necessary skills to navigate and excel in the ever-evolving world of technology.

Our mission is to cultivate a passion for coding and computer science among young learners, making the learning process enjoyable and impactful. We are confident that this series will not only help students grasp the fundamentals of coding but also inspire them to explore the endless possibilities that technology offers.

We invite you to embark on this exciting journey of learning and discovery. Let’s empower the next generation with the skills and knowledge they need to thrive in a digital world.

The NEP Tags

The National Education Policy (NEP) 2020 outlines essential skills, values, dispositions, and learning approaches necessary for students to thrive in the 21st century. This textbook identifies and incorporates these elements throughout its content, activities, and exercises, ensuring students develop coding skills and essential life skills. Referred to as “NEP Tags”, they are defined as follows:

INTEGRATED

CRITICAL THINKING

Art Integration

Bringing creativity and fun into learning by integrating art with computer science and coding

Sports Integration

Using games and sports in daily life to enrich computer-related activities

Holistic & Integrated Learning

Cross-curricular linkages to make learning-experiences more holistic and joyful and meaningful

Critical Thinking

Coding opportunities to apply higher-order skills like algorithmic and computational thinking and problem-solving

HANDS-ON

SDG

Hands-on Activity

Coding opportunities that enable learners to put theoretical knowledge into practice

Sustainable Development Goals

Coding opportunities related to real-world issues and sustainable development

SEL

Social Emotional Learning

Developing emotional intelligence and collaboration skills through coding exercises

GAMES

hands with soap keeps germs away, wearing clean clothes is another way to stay clean. Dirty clothes can collect sweat and germs, so washing them regularly helps keep our skin free of germs and itch.

1 Gather all the clothes you want to wash.

Here are the steps to wash clothes:

2 Sort your clothes by colour. Keep dark-coloured clothes in one pile and white or light-coloured clothes in another pile.

1 Gather all the clothes you want to wash.

3 Check the pockets for tissues, candy wrappers, and other items, and take them out.

2 Sort your clothes by colour. Keep dark-coloured clothes in one pile and white or light-coloured clothes in another pile.

4 Put your clothes in the washing machine, one pile at a time.

3 Check the pockets for tissues, candy wrappers, and other items, and take them out.

Discuss What is the difference between the stage and the backdrop?

4 Put your clothes in the washing machine, one pile at a time.

Discuss What is the difference between the stage and the backdrop?

Discuss: A multi-faceted probing question related to the concept that arouses curiosity

We will be using block-based coding to make computers do things for us.

Block-based Coding

We will be using block-based coding to make computers do things for us.

Block-based coding is the language in which we use colourful code blocks to tell computers what to do

Block-based Coding

You must have drawn things on a computer earlier, right?

Did You Know?

Block-based coding is the language in which we use colourful code blocks to tell computers what to do

We are going to use a block-based coding platform called Scratch 3.0 to create code for drawing and shapes.

Did You Know: Interesting facts related to the topic

What happens when you run your project?

You must have drawn things on a computer earlier, right?

The Pencil sprite moves quickly and draws the rectangle. Steps to add a delay of 1 second:

Identify and label the components based on the clues given below.

1 Click Control category in the blocks panel.

We are going to use a block-based coding platform called drawing and shapes.

Chapter Checkup

Code Snippets: Complete code for each activity with output facilitating hands-on learning and immediate feedback

A Fill in the blanks.

NEP Tags: To show alignment with NEP skills and values

a  I am a character in your project.

d  I am the area where you drag and join the blocks. Do It Yourself 1A

2 Drag the inside the repeat block.

e  I hold all the blocks for a block category.

b  I show you the options to change the name, size, and location of a character.

c  I hold colour-coded categories of blocks.

Coding

We have completed the script to draw a rectangle. Save this project with the name 'Drawing a Rectangle'.

Challenge

 Open Scratch.

2 Drag the block to after the repeat block. Code Click the Go button We have completed the script to draw a rectangle. 'Drawing a Rectangle'.

Hints menu bar  untitled  backdrop  blocks  create

Short exercises between the chapter to pause and assess comprehension

1 In Scratch, we use colourful to create our own games, stories, and drawing.

Identify and label the components based on the clues given below.

 Go to the Backdrops pane. Click on Choose a Backdrop option and select Blue Sky.

 Now, go to the sprites pane. Click on Choose a Sprite option and select the Amon sprite.

2 To create a project in Scratch, you need to click

Coding Challenge 

 The stage will look like the figure below.

3 By default, the name of the Scratch project is .

Hands-on challenges to encourage and actively engage with the concepts learnt throughout the chapter

Identify and label the components based on the clues given

4 The purple bar at the top of the Scratch editor is called the .

5 The background of the stage is called the

F Apply your learning.

Chapter Checkup

What are the other platforms you know of that assist in block-based coding? Think and Tell

Think and Tell: Analysis, reflection, and text-to-self connection-based prompts for discussion in class

e  I hold all the blocks for a block category. A Fill in the blanks.

show you the options to change the name, size, and location of a character. c  I hold colour-coded categories of blocks. d  I am the area where you drag and join the blocks.

1 Nia is making a Scratch project where she needs to move the dog from left to right. Which block should she use?

Hints menu bar  untitled  backdrop  blocks  create

Chapter Checkup: Chapter-end practice exercises aligned to different levels of Bloom’s Taxonomy

Coding Challenge  Open Scratch.

1 In Scratch, we use colourful to create our own games, stories, and drawing.

Apply your learning: Intellectually stimulating questions designed for higher-order thinking and analysis

Test Papers: Designed to evaluate understanding of core concepts and application of skills

A. Fill in the blanks.

2 To create a project in Scratch, you need to click

e  I hold all the blocks for a block category. A Fill in the blanks.

3 By default, the name of the Scratch project is

4 The purple bar at the top of the Scratch editor is called the

Hints menu bar  untitled  backdrop  blocks  create

5 The background of the stage is called the F Apply your learning.

1 In Scratch, we use colourful to create our own games, stories, and drawing.

2 To create a project in Scratch, you need to click

3 By default, the name of the Scratch project is

4 The purple bar at the top of the Scratch editor is called the

1 Nia is making a Scratch project where she needs to move the dog from left to right. Which block should she use?

Test Paper (Based on Chapters 1 to 4)

5 The background of the stage is called the F Apply your learning.

1 Nia is making a Scratch project where she needs to move the dog from left to right. Which block should she use? Chapter Checkup

Test Paper (Based on Chapters 1 to 4)

1 In Scratch, the blocks you put together in the script area are called a

A. Fill in the blanks.

1 In Scratch, the blocks you put together in the script area are called a

2 The is the background of the stage.

2 The is the background of the stage.

HANDS-ON

1

3

Working with Scratch 3.0 1

Let us make a paper whale using origami sheet by following a sequence of instructions.

Just like how we use instructions to do something step-by-step, we need to tell computers how to do something step-by-step too.

But computers do not understand our language. So, we need to use a special language that they can understand.

This language is called coding language.

Coding is a way of giving instructions to tell a computer what to do.

We will be using block-based coding to make computers do things for us.

Block-based Coding

Block-based coding is a computer language that uses colourful coding blocks to make computers do a task.

You must have played computer games, right?

But do you know you can use block-based coding to create games too?

We will use a block-based coding platform named Scratch 3.0 to create a game.

Scratch 3.0

Scratch 3.0 is a free and simple platform where we use colourful blocks to create our own games, stories, and art.

Creating a Project

Did You Know?

Scratch got its name from how DJs mix music by scratching the music discs over one another.

Now, let us learn to create a blank project and name it ‘Saving Marine Life’.

Follow the given steps to create a project.

1 Click Create. The Scratch editor opens.

2 Change the name of the project from ‘Untitled’ to ‘Saving Marine Life’.

Components of Scratch

The Scratch editor holds all the components needed to create and run a Scratch project. The components of the Scratch editor are shown in the following picture:

1 Menu bar: The purple bar at the top of the Scratch editor is called the Menu bar. The main parts of the Menu bar are:

a. File and Edit menus: These let us create, save, and open a project.

b. Project Name: This shows the name of your project. The default name of a Scratch project is ‘Untitled’.

c. Folder: Clicking here takes you to the ‘My Stuff’ page to see your saved projects.

2 Sprite: A sprite can be a character or an object in a Scratch project.

3 Tabs: There are three tabs in the Scratch editor:

a. Code: This tab has different code blocks and the coding area, also called the scripts area, where we can drag and join the blocks to make the sprite move and do things.

b. Costumes: This tab opens the Paint Editor window where we can change how a sprite looks.

c. Sounds: This tab opens the Sound editor to add and make changes to the sound effects of our sprite and to the backdrop.

4 Blocks Panel: The Blocks Panel has nine colour-coded block categories to help us create scripts. These are Motion, Looks, Sound, Events, Control, Sensing, Operators, Variables, and My Blocks.

5 Blocks Palette: The Blocks Palette is the area where we can see all the blocks for each block category.

6 Coding Area: The place where we can drag and join blocks from the Blocks palette to create a script is called Coding Area.

A Script is a set of blocks that are placed on top of each other to make a sprite do something.

7 Stage: The stage is where we can see backdrops and sprites in action.

8 Sprites Pane: The Sprites Pane is below the stage. It shows all the details of sprites, like their name, location, and size. You can use it to add, upload, edit, or delete sprites.

9 Backdrop: It is the background of the stage. You can add backdrops from the Scratch library or your computer.

10 Backdrops Pane: It is below the stage and next to the Sprites Pane. You can use it to add, upload, edit, or delete backdrops.

11 Go button and Stop button: The green flag is the Go button. You can click it to run the script. The red button is the Stop button. You can click it to stop the running script.

12 Add Extensions button: This button provides additional blocks that can be integrated into the Scratch editor’s blocks palette, expanding its functionality. These blocks help Scratch programs to interact with external hardware and online resources.

13 Sprites List: This list contains the thumbnails of all the sprites used in the project.

4

Do It Yourself 1A

Identify and label the components.

c.

a I am a character in your project.

b I show you options to change the name, size, and location of a character.

c I hold colour-coded categories of blocks.

d I am the area where you drag and join the blocks.

e I hold all the blocks of a block category.

Chapter Checkup

1 is a way of giving instructions to tell a computer what to do.

2 The is the area where we can see all the blocks of a block category.

3 The is where we can see backdrops and sprites in action.

4 The shows all the details of sprites, like their name, location, and size.

5 The button is used to stop the running script.

B Tick () the correct option.

1 Which of the following tabs does the Scratch editor contain?

a  Code

c  Sounds

b  Costumes

d  All of these

2 The Sounds tab is used to .

a  to make changes to the sound b  listen to songs

c  close the Code tab

d  open the Costumes editor

3 Where do you drag and drop the blocks to create a script?

a  Coding Area

c  Blocks Palette

b  Stage

d  Sprites Pane

4 The is used to .

a  stop the running script

c  change the costume

b  run the script

d  move the sprite

5 Which of the following is the name of a block category?

a  Motion

c  Control

C Who am I?

b  Sensing

d  All of these

Component Purpose

Sprites Pane Holds nine categories of blocks

Backdrops Pane Shows backdrops and sprites in action

Blocks Panel Shows the details of sprites

Blocks Palette Adds backgrounds

Stage Holds all blocks of each block category

D Write T for True and F for False.

1 The default project name in Scratch is Project1.

2 You can add and make changes to the sound effects of the sprite and backdrop in the Sound Editor.

3 The green flag button is used to stop the running project.

4 Events is one of the categories of blocks.

5 The colour of the Go button is green.

E Answer the following questions.

1 What is block-based coding?

2 What is Scratch 3.0?

3 What is the role of the Code tab?

4 What does the Add Extension button help us with?

5 Describe the Go and Stop buttons.

F Apply your learning.

Tisha wants to learn coding, but she has not tried it before.

1 What coding language can she start learning? Why?

2 What should she add to her project to do the action?

3 What can she use to add more blocks?

4 How can she make her sprite look different?

5 What can she use to change the background of her project?

Sprites and Backdrops 2

Suppose you are going to a jungle-themed party. You will need to wear a costume according to the character you are playing; it can be a person, plant, animal, or any other object.

Sprites

In Scratch, a sprite is a character or an object on the stage.

Just like how you change your costume to play different characters, a sprite can also change its costume.

A costume is the appearance of a sprite.

You can change the sprite’s costume to make it look like it is moving, changing, or doing many things in your project.

Sprites Library

You can add sprites from the Sprites Library of Scratch or your computer.

You can also draw or edit your sprite as per your need.

A Sprites Library is a collection of ready-to-use sprite images.

Did You Know?

Red sprites are big red flashes of light that happen high in the sky during thunderstorms. They are so big that they can be seen from space.

The idea of the ‘Saving Marine Life’ project is to make the crab (saviour) sprite catch the milk (trash) sprite to protect the underwater creatures. So, in this project, we need the following sprites:

To start the project, we need to add our sprites. As you know, the Cat sprite is the default sprite in Scratch. Before adding the sprites for our project, we need to remove the Cat sprite.

Deleting a Sprite

To delete the Cat sprite:

1 Select the thumbnail of the Cat sprite from the Sprite List.

2 The Delete button will appear.

3 Click the Delete button to delete the sprite.

Crab Milk

Ways to Add a Sprite

In Scratch, we can add a sprite in four ways.

1 Choose a Sprite – To choose a sprite from the Sprites Library.

2 Paint – To create a sprite using Paint Editor.

3 Surprise – To add a random sprite.

4 Upload Sprite – To upload a sprite that is already saved on the computer.

Choosing a Sprite

Now, let us add our first sprite, the Crab, from the Sprites Library into our project.

Steps to add a sprite from the Sprites Library:

1 Click the Choose a Sprite option in the Sprites Pane.

2 The Sprites Library will open.

3 Click the Crab sprite.

Choose a Sprite Paint Surprise
Upload Sprite

4 The sprite appears on the stage and its thumbnail is added to the Sprites List.

5 Change the Size of the Crab sprite to 40 from the Sprites Pane.

Similarly, add the Milk Sprite from Sprites Library and set its size to 30. The Sprites Pane will look like this.

Renaming a Sprite

Let us rename the sprites for our project. Follow the given steps to rename a sprite:

1 Click on the sprite you want to rename in the Sprites Pane.

2 Click on the Sprite text box and delete the default name.

3 Type in the new name for your sprite. For this project, let us rename the Crab sprite as Saviour and the Milk sprite as Trash.

4 Press Enter or click outside the text box.

5 The new name will reflect in the Sprites Pane.

Ways to Add a Backdrop

It is time to add a background to our project.

The way we add sprites in Scratch, we can also add backgrounds from the Backdrops Pane. There are four ways to add a backdrop.

1 Choose a Backdrop – To choose a backdrop from the Scratch Backdrops Pane.

2 Paint – To create a backdrop using Paint Editor.

3 Surprise – To add a random backdrop.

4 Upload Backdrop – To upload a backdrop from the computer.

Choosing a Backdrop

Now, let us add the Underwater 1 backdrop to the Stage. Steps to add a backdrop to the project:

1 Click the Choose a Backdrop option in the Backdrops pane.

2 The Backdrops Library will open.

3 Search for the Underwater 1 backdrop by typing its name in the search bar.

4 Click the Underwater 1 backdrop. The backdrop appears on the stage and its thumbnail is added in Backdrops Pane.

Let us create a sea bed in our backdrop using the Paint option.

Painting a Backdrop

1 Click on the thumbnail of the backdrop in the Backdrops Pane.

2 Click on the Backdrops tab on the left side of the screen. The paint editor for the backdrop will open.

3 Choose the colour of the sea bed using the Fill option.

4 Set the colour to 17, saturation to 56, and brightness to 58.

5 Select the Rectangle tool.

6 Draw a rectangle on the lower portion of the backdrop.

7 Click on the Outline option and pick the color picker tool.

8 Select the same colour from the rectangle and hover it over the outline to make the outline of the same colour.

9 You will see the sea bed created on the backdrop.

10 Finally, our stage is set for our project.

Do It Yourself 2A

1 Tick ()  the food sprite from the following.

2 Search for the following backdrops in the Backdrops library and write their names.

A Fill in the blanks.

1 is a character or an object who acts on the stage.

2 A is a collection of ready-to-use sprite images.

3 is the appearance of a sprite.

4 The option is used to add a backdrop from our own computer.

5 There are ways to add a backdrop.

B Tick () the correct option.

1 Which of the following options can let you add your own picture as a sprite?

2 Which option is used to set the colour while using the Paint option.

3 Which option is used to make the sprite big or small?

4 Which of the following options is used to change the background of the stage?

1 I can show different scenes, such as a forest, a city, a farm, or a school.

2 I can remove a sprite from a Scratch project.

3 I help you change the name of a sprite.

4 I am used to add a random sprite.

5 I can add a backdrop from your computer.

D Write T for True and F for False.

1 Sprites are characters or objects that can move, talk, and interact on the stage.

2 Upload Sprite option is used to upload a sprite that is already saved on the computer.

3 We can add only one sprite in the Scratch project.

4 Backdrops are the backgrounds used to set the stage for a project.

5 There is only one way to add a sprite.

E Answer the following questions.

1 Which component in a Scratch project can act? How can we add it to our project?

2 What is the role of Backdrops Pane in Scratch?

3 How can we delete a sprite?

4 How can we

5 Write the ways to add a backdrop in a project.

F Apply your learning.

1 Ria wants to create and design her project to showcase the benefits of games in our life as shown.

a What option can she use to delete the default sprite in her project?

b Which component of Scratch Editor can help her add a new backdrop to the stage?

GAMES

2 Label the elements in the given picture.

3 Arjun is creating a Scratch project in which he wants to remove some parts of the backdrop. Which option can he use to do this?

4 Ravi wants to add three new sprites to his Scratch project, which he has downloaded from the internet. Which option will help him complete the task?

Events and Loops 3

Riya and Jay’s school has organised a summer carnival in the school. The school has sent the invitations to all the students.

Riya and Jay have decided to go to the carnival after receiving the invitation. Here, receiving the invitation is an event and going to the carnival is the action.

An event tells us when an action will happen. An action happens when an event occurs.

Events Blocks

In Scratch, we have various Events blocks. They are yellow in colour.

They tell the computer when to run a script.

Some of the Events blocks are:

Blocks

Did You Know?

The Events blocks are also known as Hat Blocks.

Description

Runs the attached script when the green flag is clicked.

Runs the attached script when the specified key is pressed.

Runs the attached script when the particular sprite is clicked.

In the previous chapter, we designed our Scratch project ‘Saving Marine Life’ by adding sprites and a backdrop.

Now, let us code the sprites to do some actions.

Before we start, do you remember the idea of the project?

The idea is to make the saviour sprite catch the trash sprite to protect the underwater creatures, remember?

Now, we need to break the idea into smaller tasks.

Let us divide the whole project into five subtasks:

1 Show a message from the saviour to catch the trash.

2 The saviour should be able to move left and right using the left and right arrow keys.

3 The trash should appear randomly and start falling.

4 If the falling trash touches the saviour, the trash should disappear.

5 If the falling trash touches the sea bed, the trash should display a message.

Let us start coding the saviour sprite.

Making a Sprite Say Something

We will use the Say block to make the sprite talk. The Say block is found in the Looks category of blocks.

Looks blocks are used to control how a sprite looks. They are purple in colour.

Blocks

Description

Using this block, a speech bubble appears over the sprite and stays for the specified number of seconds.

Steps to make a sprite say something:

1 Select the Saviour sprite.

2 Drag and drop the when green flag clicked block from the Events category in the Scripts Area.

3 Drag the say Hello! for 2 seconds block from the Looks category and join it to the when green flag clicked block.

4 Change ‘Hello!’ with ‘Help me catch the trash.’

5 Click the Go button to check if the Saviour says the specified message.

Now, you must have observed that the saviour is showing the message at a random position. Let us move the sprite at a specified position with the help of Motion blocks.

Motion Blocks

Motion blocks are used to control the movement of the sprites.

They are blue in colour. There are various Motion blocks. Some of them are:

Blocks

Description

Moves the sprite to the specified x and y positions.

Changes the x position of a sprite by a specified value. Moves the sprite forward or backward with positive or negative values, respectively.

Changes the y position of a sprite by a specified value. Moves the sprite upwards or downwards with positive or negative values, respectively.

Moves the sprite to any random position.

Blocks Description

If touching the edge of the screen, the sprite bounces back.

Sets the rotation style of a sprite.

Set the direction of the current sprite.

X-Axis Y-Axis

A sprite’s X Position is its location on the X (horizontal) axis of the stage.

The Y Position is where the sprite is on the Y (vertical) axis of the stage.

Follow the steps to move the sprite to the specified position:

1 Drag and drop the go to x: () y: () block from the Motion category in the Scripts Area.

2 Change the value of x to –182 and y to –136.

3 Join it below the when green flag clicked block.

4 Then, attach the say () for () seconds block to the go to x: () y: () block.

5 Click the Go button to check if the Saviour says the message at a specified position.

1 Match the following blocks with their description.

Column A

2 Guess the correct block category.

a I am yellow in colour.

b I am purple in colour.

c I am blue in colour.

Column B

Sets the direction of the current sprite.

Makes the sprite say Hello for 2 seconds.

Runs the attached script when the green flag is clicked.

Moves the sprite to any random position.

Loops

Imagine your community is having a tree planting event, and you are going to join in with your parents.

Suppose you have to plant 10 saplings. How will you do that? You will be planting saplings, one after another. This repeating action is called a loop.

A loop means doing something over and over again.

In Scratch, we have repeat and forever control blocks that are used to repeat actions. In coding, we use loops to save time to build our scripts quickly.

Control Blocks

The Control blocks are used to control the flow of scripts based on some criteria. They are orange in colour. Some of the Control blocks are: Blocks Description

Sensing Blocks

A loop that repeats actions for the specified number of times. Runs the given set of blocks forever until the Stop button is pressed.

Pauses the script for specified seconds.

Checks the condition and if the condition is true, the blocks inside it will be activated.

How do you react when you touch a hot object? You immediately remove your hand, right? This means you react when you sense something. Similarly, we can make sprites sense each other when they touch.

In Scratch, we have Sensing blocks to do this. Sensing blocks are used to detect when two characters touch each other.

They are used to detect other sprites, colours on stage, keypress, mouse click, and user input.

There are 18 Sensing blocks. They are light blue in colour.

Some of the Sensing blocks are:

Blocks Description

Moving a Sprite

Steps to move the Saviour sprite:

Activates the blocks below it when a sprite touches the specified object.

Activates the blocks below it when a sprite touches the specified colour.

Activates the blocks below it when the specified key is pressed.

1 Select the Saviour sprite in the Sprites List.

2 Go to the Control block category.

3 Drag and join the forever block below the say block.

4 Drag and join the if… then block from the Control category inside the forever block.

5 Drag the key space pressed block from the Sensing category to the blank section of the if… then block.

6 Click the drop-down button in the key space pressed block and change space to right arrow.

7 Drag and join the point in direction block inside the if… then block.

8 Drag and join the change x by block under the point in direction block inside the if... then block.

9 Change the value of x to 10.

10 Click the Go button to test if the sprite moves in the right direction.

Similarly, create the code to move the sprite in the left direction by changing the value of the key space pressed block to the left arrow and changing the value of x to -10.

The code will look like this:

Now, we have done the coding of the Saviour sprite. Let us now start coding the Trash sprite.

Making a Sprite Fall

Steps to make the Trash sprite fall:

1 Select the Trash sprite in the Sprites List.

2 Drag and drop the when green flag clicked block from the Events category in the Scripts Area.

3 Drag and drop the go to x: () y: () block from the Motion category in the Scripts Area.

4 Change the value of x to 9 and y to 155. Join it below the when green flag clicked block.

5 Drag and join the forever block to the go to to x: () y: () block.

6 Go to the Motion block category.

7 Drag and join the change y by block inside the forever block.

8 Change the value of y by -10.

9 Go to the Control block category.

10 Drag and join the wait () seconds block under the change y by -10 block inside the forever block.

11 Change the seconds to 0.2.

12 Click the Go button to test if the sprite appears at a random position and falls forever.

The project will look like this.

1 Select the correct code to make the sprite go to random position. Do It Yourself 3B

A Fill in the blanks.

1 The block moves the sprite to any random position.

2 A means doing something over and over again.

3 To create repeating actions, you can use the block in a script.

4 The Motion blocks in Scratch are in colour and are used to add motion to a sprite.

5 An tells you when the action will happen.

B Tick () the correct option.

1 Which of the following blocks is used to run the script when the up arrow key is pressed?

2 Which is the correct script to make a sprite fall forever?

3 Which of the following blocks move a sprite upwards?

4 Which of the following blocks is used to run the script until the Stop button is pressed?

d   All of these

5 blocks are purple in colour.

a  Motion

c  Looks

C Who am I?

Who Am I ?

D Write T for True and F for False.

1 Kicking a football is an event.

b  Sensing

d  Control

What I Do?

Moves the sprite forward or backward with a positive or negative value, respectively.

Moves the sprite upwards or downwards with a positive or negative value, respectively.

Pauses the script for specified seconds.

2 The Say block is used to make the sprite talk in Scratch.

3 Repeating action in coding means doing something only once.

4 Motion blocks are used to control the movement of the sprites.

5 The block in Scratch runs a script when the green flag is clicked.

E Answer the following questions.

1 How is the repeat block helpful?

2 If you use these blocks, how will they change the position of the sprite?

3 What are Events blocks?

4 What will happen to the sprite if we run this code?

5 Differentiate between the repeat and forever blocks.

F Apply your learning.

1 Look at the blocks given below and number them from 1 to 4 in order to make the sprite fall when the Go button is pressed.

2 What will be the output of the following script?

3 Write the script to display this message.

4 Along which axis is the Penguin sprite moving? Can you explain the reason?

Using Sensing Blocks 4

Friends, do you know yesterday my father told me about traffic signals? Red means stop, green means go, and yellow means get ready to go. Based on the colour of the lights, we know when to go and when to stop. This helps keep everyone safe and traffic moving smoothly.

In the previous chapter, we made the sprites say something, move, and fall.

Now, we need to build a code to accomplish the following:

1 If the falling trash touches the saviour, the trash should disappear.

2 If the falling trash touches the sea bed, the trash should display a message.

In the last chapter, you learnt about the Sensing blocks. Let us again use some of the Sensing blocks to proceed further in our project.

Making a Sprite Disappear on Touching Another Sprite

To make a sprite disappear and then come back from a random place, we can just move the sprite to a random position.

The steps to make the Trash move to a random location if it touches the Saviour are as follows:

1 Drag and join the if… then block from the Control category under the wait 0.2 seconds block inside the forever block.

2 Drag the touching mouse-pointer block from the Sensing category to the blank section of the if… then block.

3 Click the drop-down button in the touching block and change the mouse-pointer to Saviour.

4 Drag the wait 1 seconds block from the Control category and join it inside the if… then block.

5 Change the value of the wait 1 seconds block from 1 to 0.5.

6 Drag the go to random position block from the Motion category and join it under the wait 0.5 seconds block.

Making a Sprite Display a Message on Touching a Colour

The steps to make the Trash sprite display a message if it touches the sea bed.

1 Drag and drop the if… then block below the existing if… then block.

2 Drag the touching color? block from the Sensing category to the blank section of the if… then block.

3 Select the color in the touching block and change the colour to that of the sea bed.

4 Drag the say Hello! for 2 seconds block from the Looks category and join it to the touching color? block.

5 Change ‘Hello!’ with ‘Oops! I am harming marine life.’

6 Drag the wait 1 seconds block from the Control category and join it under the say block inside the if… then block.

7 Drag the go to random position block from the Motion category and join it under the wait 1 seconds block.

Do It Yourself 4A

1 Choose the correct way to help the juice sprite reach the jug.

Chapter Checkup

A Fill in the blanks.

1 blocks are used to detect things on the stage, like the mouse pointer, an object, or other sprites.

2 Sensing blocks are in colour.

3 The sensing block activates the blocks below it when a sprite touches the specified object.

4 There are sensing blocks.

B Tick () the correct option.

1 In Scratch, what type of blocks help sprites sense each other?

a  Motion blocks    b  Sensing blocks    c  Sound blocks    d  Looks blocks

2 What should happen to the Trash sprite if it touches the Sea bed?

a  It should break b  It should display a message

c  It should disappear d  It should change colour

3 Which block is used to make a sprite react on touching another sprite?

4 What is the aim of the Saviour sprite in the Saving Marine Life project?

a  To catch the trash

c  To throw the trash

b  To kill the trash

d  To spread the trash

5 You can select the wait 1 seconds block from category.

a  Event b  Sensing

c  Control d  Motion

Who Am I ?

D Write T for True and F for False.

What I Do?

Activates the blocks below it when a sprite touches the specified colour.

Checks the condition and if the condition is true, the blocks inside it will be activated.

Activates the blocks below it when a sprite touches the specified object.

1 Sensing blocks are used to make a character react when you click it or press a key.

2 The touching mouse-pointer block helps detect when a sprite touches a specific object.

3 You can use the ‘wait’ block to pause the execution of the script for a specified amount of time.

4 Sensing blocks are not used to make Scratch projects more interactive by responding to the user input.

5 The ‘if... then’ block performs a specified task only if a certain condition is met.

E Answer the following questions.

1 What are sensing blocks?

2 Write the use of touching color block.

3 How can you make a character in Scratch react when you click on it?

F Apply your learning.

1 Look at the blocks given below. Number them from 1 to 3 in order to make the Trash sprite disappear if it touches the Saviour.

2 What will be the output of the following script?

3 Observe the script and write down what this script will do. Also, tell under which category these blocks appear.

A. Fill in the blanks.

Test Paper (Based on Chapters 1 to 4)

1 The button is used to run the script in Scratch.

2 is used to add a random backdrop.

3 An event tells us when an will happen.

4 blocks are used to detect when two characters touch each other.

B. Tick () the correct option.

1 Which option is used to set the colour while using the Paint option.

a  Fill

c  Outline

b  Rectangle

d  Text

2 Where do you drag and drop the blocks to create a script?

a  Coding Area

b  Stage

c  Blocks Palette d  Sprites Pane

3 blocks are used to control the movement of the sprites.

a  Looks b  Sensing

c  Motion d  Events

4 tab opens the Paint Editor window where we can change how a sprite looks.

a  Code b  Costume

c  Sound d  All of these

C. Write T for True and F for False.

1 Answer blocks stores the answer that was entered in the input box.

2 Repeating action in coding means doing something only once.

3 The default project name in Scratch is Untitled.

4 Backdrops are the backgrounds used to set the stage for a project.

D. Answer the following questions.

1 What is a Sprites Pane?

2 What is the use of control blocks?

3 Write the use of touching <mouse pointer> block.

4 What is the purpose of sensing blocks?

E. Apply your learning.

1 Write the script to display the message ‘Health is wealth!’

2 Observe the script and write down the output. Are you hungry? Eat an apple.

3 Raj wants to add a backdrop to his Scratch project, which is saved on his computer. Which option will help him complete the task?

About the Book

This coding book is supplementary to the main “Mel and Conji” content book. This book represents a 21st-century approach to learning coding concepts and developing computational thinking and problem-solving skills. To prepare students for the digital age, the curriculum is interwoven with well-thought-out concept progression, real-life examples, and practice problems.

Special Features

• Project-based learning: Engaging hands-on projects encouraging practical application of computer science and coding.

• NEP Tags: To showcase alignment with NEP skills and values.

• Code snippets: Complete code for each activity with output facilitating hands-on learning and immediate feedback.

• Coding challenges: Includes projects through which learners can demonstrate their learning outcomes in coding and computer science.

• Test Papers: Designed to evaluate understanding of core concepts and application of skills.

About Uolo

Uolo partners with K-12 schools to provide technology-enabled learning programs. We believe that pedagogy and technology must come together to deliver scalable learning experiences that generate measurable outcomes. Uolo is trusted by over 15,000+ schools across India, Southeast Asia, and the Middle East.

ISBN 978-81-979297-5-5 Not to be sold separately

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.