

COMPUTER SCIENCE Coding Book


Computer Science Coding Book Tekie.AI

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 edition 2023
Second edition 2024
Third edition 2025
Fourth edition 2026
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.AI Computer Science Coding Book 5
ISBN: 978-81-992716-8-5
Published by Uolo EdTech Private Limited
Corporate Office Address: 91Springboard, 3rd Floor
145, Sector 44, Gurugram, Haryana 122003
CIN: U74999DL2017PTC322986
Printed by: Printpro Solutions
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, computational thinking, and artificial intelligence has reached unprecedented heights. In today’s professional landscape—be it medicine, space exploration, education, science, or business—AI is transforming every sector.
Recognising this imperative, the National Education Policy (NEP) 2020 has strongly recommended the integration of coding, computational thinking, AI awareness, and problem-solving abilities into the curriculum. Moreover, future-ready subjects like Artificial Intelligence, Data Science, and emerging technologies are now at the core of education reforms. It is evident that AI will soon become an integral part of learning even at the elementary level.
Uolo has introduced an innovative 360-degree program for an AI-driven computer science curriculum, known as Tekie.AI, spanning grades 1 to 8. Tekie.AI is a significant stride towards STEM and AI education, empowering learners with skills needed to excel in an intelligent, technology-driven world.
This coding book is part of the larger Tekie.AI program, a modern pathway to learning Artificial Intelligence concepts alongside computer science. It nurtures not only knowledge but also computational thinking, creativity, and critical thinking skills.
In addition to the textbooks, we offer a dynamic digital platform where students actively engage in practical activities and hands-on projects. This platform enriches the learning journey by enabling learners to experiment, explore, and apply their knowledge in real-world contexts. The package comes with digital content, provided free of cost, to ensure a seamless and holistic learning experience for children.
Every activity in our coding books has been thoughtfully designed and aligned with the National Education Policy (NEP) 2020, which emphasises a holistic and future-ready approach to education. Through this alignment, we aim to foster logical reasoning, critical thinking, and practical problem-solving skills in students, preparing them to thrive in the ever-evolving world of technology. To further strengthen this experiential learning, we have included AI Projects in each book of the series, encouraging students to connect classroom concepts with innovative, real-life applications.
Our mission is to ignite a passion for coding and computer science among young learners, making the process not just educational but also enjoyable and inspiring. We believe this series will not only strengthen students’ foundations in coding but also empower them to explore the endless frontiers of technology with curiosity and confidence.
Welcome to the captivating realm of Tekie.AI! We hope you enjoy this educational journey as it equips you with the skills to thrive in an exciting, intelligent, and ever-changing 21st-century 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
Hands-on Activity
Coding opportunities that enable learners to put theoretical knowledge into practice

SDG
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


Here are the steps to wash clothes:
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
Did You Know?
You must have drawn things on a computer earlier, right?
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
Block-based coding is the language in which we use colourful code blocks to tell computers what to do.
You must have drawn things on a computer earlier, right?
We are going to use a block-based coding platform called Scratch 3.0 to create code for drawing and shapes.

Chapter Checkup
Code Snippets: Complete code for each activity with output facilitating hands-on learning and immediate feedback
e I hold all the blocks for a block category.
A Fill in the blanks.
NEP Tags: To show alignment with NEP skills and values




















Hints menu bar untitled backdrop blocks create

1 In Scratch, we use colourful to create our own games, stories, and drawing.
Short exercises between the chapter to pause and assess comprehension
2 To create a project in Scratch, you need to click .
Coding Challenge
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
4 The purple bar at the top of the Scratch editor is called the .


F Apply your learning.
Chapter Checkup
Identify and label the components based on the clues given

5 The background of the stage is called the .
AI Projects: To transform coding concepts into powerful simulations of real-world intelligence.
c I hold colour-coded categories of blocks.
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.
1 Nia is making a Scratch project where she needs to move the dog from left to right. Which block should she use?
d I am the area where you drag and join the blocks.
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.
To create a project in Scratch, you need to click By default, the name of the Scratch project is
The purple bar at the top of the Scratch editor is called the

The background of the stage is called the
In Scratch, we use colourful to create our own games, stories, and To create a project in Scratch, you need to click By default, the name of the Scratch project is 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.
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

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)
1 In Scratch, the blocks you put together in the script area are called a
A. Fill in the blanks.
2 The is the background of the stage. Test Paper (Based on Chapters 1 to 4)

1 In Scratch, the blocks you put together in the script area are called a
2 The is the background of the stage.
HANDS-ON
1
• Coding
• Scratch 3.0
• Starting Scratch 3.0
• Project: Quiz Master
• Adding a Sprite
• Duplicating a Sprite
• Adding Backdrops 2

Introduction to Scratch 3.0 1




Help the bunny reach its favourite food.
Just like you solve a problem by helping the bunny reach its favourite food, coding helps a computer perform tasks or solve problems.
Coding
Coding is the process of creating sets of instructions that a computer can understand and execute. Coding is a way to tell a computer what to do. It involves writing specific commands in a programming language to tell a computer how to perform tasks, solve problems, or run applications. We can use coding to develop software, websites, mobile apps, and other digital technologies.




Did You Know?
Computer programmers sometimes use secret codes to leave messages for each other. It is like having a secret club! They call it ‘Easter eggs’.
Block-based Coding
Block-based coding makes it easier for kids to learn to program because it is like putting together a fun and colourful jigsaw puzzle! Instead of typing complicated words and numbers, you use colourful blocks with pictures on them to create programs.
Each block represents a different action or command, and you snap the blocks together like puzzle pieces to make the computer do what you want. Scratch, Tynker, and LightBot are a few examples of block-based coding languages that help us learn and practice our coding skills.
Discuss
Do you and your friends have a secret language that you people talk in? or Codes?
Why do you make it and how do you use it?
Do It Yourself 1A
Fill in the blanks.
1 is used to develop software, websites, mobile apps, and other digital technologies.
2 In block-based coding, you use colourful with pictures on them to create programs.
3 Scratch is an example of a coding language.
Scratch 3.0
Scratch 3.0 is an application program that lets you create your games, stories, and animations. It is a free platform where you can show your creative skills.
You can make characters move, jump, and talk, and you can even make your own interactive stories or games.
Scratch 3.0 is all about using your creativity and imagination to make programs on a computer, and the best part is that you can share your creations with your friends and see what they make too!


Did You Know?
Scratch was originally developed by the Lifelong Kindergarten Group at the MIT Media Lab to help kids learn to code in a fun and creative way.
Starting Scratch 3.0
Here are the steps to get started with Scratch:
Think and Tell
What are the other platforms you know of that assist in block-based coding?
1 Open a web browser like Google Chrome or Microsoft Edge.
2 Go to the Scratch website by typing www.scratch.mit.edu in the address bar and then pressing Enter.
3 Click the Start Creating button on the Scratch website to begin creating your projects. The Scratch interface appears.

Components of Scratch

1 Menu and Title Bar: Here, you will discover menu options for project management and Scratch environment control.
Settings It provides options for Language and Colour Mode settings.
File It has options like New, Load from your computer, and Save to your computer.
Edit In the Edit icon, you can enable Turbo Mode, which significantly speeds up the execution of your Scratch project, making your code run faster, which is useful for complex or time-sensitive scripts.
2 Tabs: Used for switching between Code, Costumes tabs, and Sounds, with stage resizing icons.
3 Blocks Panel: Contains various categories of coding blocks like Motion, Looks, Sound, etc., for controlling sprite actions, colour-coded for ease.
4 Blocks Palette: Offers diverse coding blocks; drag and drop to create scripts and bring ideas to life in Scratch.
5 Coding Area: Where you assemble coding blocks to create scripts and make your sprites perform actions. It is also known as the scripts area.
6 Stage: The area where sprites interact and display the results of your code.
7 Sprite: Characters or objects in your project that you can program to move, talk, and interact.


8 Backdrop: Various backgrounds for the stage to set the project’s setting, customisable and importable.
9 Go Button: The green flag button is used to run your project.
10 Stop Button: The red circle button stops or pauses your project when it is running.
11 Sprites Pane: Located under the stage, it contains details about sprites, including name, size, and location. Here, you can edit, upload, or change sprites.
Match the following.





Creating a Quiz Master game is an easy way to learn Scratch 3.0.
Project: Quiz Master
Pane
Coding Area
In this book, we will create a Quiz Master project in Scratch, through which we will learn various concepts of Scratch.
Sprites
Sprite
Blocks Panel Go Button
Steps to create the project:
Use Scratch’s block-based coding to create an interactive quiz game.
You can use sprites and backgrounds to show characters and settings in your story.
The sprite Pico will tell the rules of the game first.
Use variables to keep track of the scores.
Pico will ask questions. If the answer is correct, the score will increase by 10 points, and a clapping sound will play. If the answer is incorrect, the score will stay the same, and a losing sound will play.
Adding a Sprite
The main character that performs all the action in your project is known as a Sprite. The default sprite in Scratch is a Cat. You can change or add more sprites to your project per your choice.
Before adding a new sprite you can delete the existing sprite by clicking on the delete button in the Sprites pane.
Follow the given steps to add a sprite in your project:
1 Click on the Choose a Sprite button.
2 Select Choose a Sprite.

Upload Sprite
Surprise
Choose a Sprite Paint delete button
Choose a Sprite button.
3 The Choose a Sprite dialog box appears. Click on the desired sprite. The selected sprite appears on the stage.


If you want to draw your own sprite or upload an already drawn sprite, Scratch provides Paint and Upload Sprite options to do so. In our case, we have selected the Pico sprite.
Changing Costume
Changing costume allows you to give your sprite a different look. Steps for changing costumes in Scratch are:
1 Click on the sprite you want to change the costume for in the Sprites pane.
2 Click on the Costumes tab.
3 You will see the following screen. Choose from the available costumes on the left to change the costume.

3
You can also paint a new costume to draw your own sprite.
Animating a Sprite
Now, to animate your sprite in Scratch:
1 Click on the Events category.
2 Drag the when clicked block.

3 Click on the Looks category.
4 Drag the next costume block and snap it below the when clicked block.
5 Click on the green flag button. The sprite changes its costume on every click.

Think and Tell
While you design the costume for your sprite, in your opinion, what colours look the best on your sprite?
A Fill in the blanks.
1 is the main character that performs all the tasks in your project.
2 To make our sprite change its costume, we drag the block from the Looks category.
3 To see a library full of various characters and pictures, we must click .
4 The and blocks are used to animate the costume change of a sprite.
B State True or False.
1 You cannot change the costume of a sprite.
2 The default sprite in Scratch is a Cat.
3 The green flag button is also called the Go button.
4 You cannot add more than one sprite in a project. Do It Yourself 1C

Duplicating a Costume
You can make your sprite wear the same costume twice. To duplicate a costume in Scratch for a sprite, follow the given steps:
1 Click on the sprite you want to duplicate a costume for in the Sprites pane.
2 Select the Costumes tab.
3 Click the costume to select it.
4 Right-click the selected costume. A context menu appears.
5 In this menu, click duplicate, and a copy of the costume is created.
Scratch gives the duplicated costume with the same name as the sprite along with the suffix 2, 3, or so on. For example, we have duplicated Pico-b and so, the duplicated costume’s name will be Pico-b2.
You can switch between costumes using the switch costume to block. You need to specify the names of the costumes in this block.
Do It Yourself 1D





Duplicating a Sprite
Steps to duplicate a sprite in Scratch are as follows:
1 In the Sprites pane, click the sprite you want to duplicate.
2 Right-click the sprite, which opens a menu.
3 Select the duplicate option to create a copy of the selected sprite.
4 The duplicated sprite will appear with the same name as the sprite along with the suffix 2, 3, or so on.
For example, on duplicating the Pico sprite, the name will be Pico2, Pico3, and so on.
To duplicate a sprite using code:
1 Drag the when clicked block from the Events category.
2 Click the Control category.

3 Drag the create clone of myself block in the script area.

4 Click on the green flag button. The duplicated sprite will overlap the existing sprite. You can change the location by dragging the sprite.

Adding Backdrops
You can add backgrounds, also known as backdrops, to your project to create various settings or scenes for your sprites to interact with. Here’s how you can add a background:
1 Click on the Choose a Backdrop button in the bottom right corner of the interface.
2 Select Choose a Backdrop.

3 The Choose a Backdrop dialog box opens. You can scroll through the library to find a backdrop you like.

4 Click the backdrop you want to use from the library. The selected backdrop replaces the current backdrop on the stage.

Changing Backdrops
If you want to change the background while your project is running, you can use special code blocks to do it.
1 Add some backdrops of your choice in your project.
2 Drag the when clicked block from the Events category.
3 Drag the next backdrop from the Looks category and snap it below the when clicked block.

4 Play the project by clicking on the green flag button. You can observe the backdrop getting changed.

A Fill in the blanks.
1 To duplicate the costume of the sprite, you must select the
2 In case you want to add more backdrops, you will get them from the
3 uses colourful blocks with pictures on them to create programs.
4 is represented as a red circle that allows you to stop or pause your project if it is running.
5 is under the stage; it has all details about the sprite.
B Who am I?
1 I am also known as programming; I give instructions to the computer that it executes.
2 I am the area in the Scratch window that contains various categories of blocks.
3 I am a category of blocks that contains the when clicked block.
4 I am a free software that allows you to design your own games and animations through scripts.
5 I am the area in the Scratch window where you can code.
C Explain the function of the following. 1





D Write T for True and F for False.
1 The blocks panel is where you can find a wide range of coding blocks to use in your scripts.
2 To change a costume, first go to the Code tab.
3 You need to click the Paint option to create your own backdrop.
4 You can assemble and connect the coding blocks to create scripts in the coding area.
5 You cannot customise a sprite according to your choice.
E Answer the following questions.
1 What is Scratch 3.0?
2 What is the Sprite Pane?
3 Which option is used to add a sprite to a project?

4 What is the Coding area?
5 Write the steps to duplicate a costume in Scratch 3.0?
F Apply your learning.
1 Draw a panda in the Scratch paint editor and use it as a sprite. Also, assign a suitable name to your sprite.
2 Shreya wants to add a forest background in a Scratch project. Help her choose a background by writing the steps.
3 Meenal has made an amazing design in Scratch but doesn’t know how to duplicate a costume. What should she do?
4 Tanu is making a project in Scratch for her school’s annual day function in which she needs to add the same sprite five times. How can she do this?
5 Seema has created a project in Scratch for the birthday of her brother in which she wants to display some photos one by one as the background. Which two blocks should she use to do so?
Variable and Looks Blocks 2
Scratch is an event-driven programming language. This means that actions are triggered by events, such as clicking a sprite or pressing a key, making it easy to create interactive animations and games.
Project: Quiz Master
Let us continue with our project: Quiz Master.
1 The Pico sprite will explain the rules of the game first and then ask questions.
2 If the answer is correct, the score will be increased by 10, and a clapping sound will play.
3 Else, the score will remain the same, and a losing sound will play.
Project Setup
Open Scratch and then continue with your project. In the previous chapter, we had set up the Pico sprite and the backdrop to Chalkboard, as shown in the given figure.

Variable Blocks
Variable blocks are the blocks that help a computer store a value that can be changed throughout a project. Variables can be used to store numbers and text.
In Scratch, a variable can contain two types of values: numeric and textual or string.
Numeric Variable It is used to store numbers.

String Variable It is used to store text.

Adding a Variable
Follow the given steps to add a variable, Score, to our project.
Did You Know?
Scratch can be used on various platforms, including web browsers, Windows, macOS, and Linux, making it versatile and widely compatible.
1 Drag the when clicked block from the Events category to the scripts area.
2 Select the Variables category.
3 Click on the Make a Variable button.

4 The New Variable dialog box appears. Assign a name to the new variable, for example, Score.

5 Click on OK. The variable is added to the list. After adding a variable, let us learn how to set a value of the variable.

Setting Value of the Variable
To set the value of the variable, we can just add the set variable to block.
1 Drag the set variable to block from the Variables category to the scripts area.

2 Click on the variable drop-down menu and select the variable you want to set the value of. In our case, it is the Score variable.


3 Type the value you want to set the variable to. The value can be a number or text. In this case, we need the value ‘0’ only. Click here to change the value

4 The value of the variable Score is now set to 0.
Now let us make the Pico sprite say the rules of the quiz using the Looks blocks.
Looks Blocks
The Looks block category contains various blocks that are used to change the looks of the sprite and to make the sprite say something. This category of blocks is used to create dialogues in the game or the project.
There are 20 Looks blocks.
Some of them are:
Blocks










Description
A speech bubble appears over the sprite and stays for the specified number of seconds.
A thought bubble appears over the sprite and stays for the specified number of seconds.
Changes the sprite’s costume to the specified one.
Changes the sprite’s costume to the next one in the costume list.
Changes the stage’s backdrop to the specified one.
Changes the stage’s backdrop to the next one in the costume list.
Changes the sprite’s size by the amount.
Set the sprite’s size according to the specified percentage.
Shows the sprite.
Hides the sprite.

Discuss
How important is it to time the display of a message using the say block?
Now, let us make the Pico sprite explain the rules of the game using the say block. The steps to make a sprite say something are:
1 Drag the say Hello! for 2 seconds block from the Looks category and join it to the set score to block.
2 Change “Hello!” with “Welcome to my quiz show!”
3 Click on the Go button to check if the Pico sprite says the specified message.

Similarly, add the following rules to the quiz.
I will ask you five math questions.
For every right answer, you will get 10 points.
For a wrong answer, you will not get any points.
Let’s start!

Did You Know?
You can change the number of seconds for which a message should be displayed on the screen.
1 Look at the following code and fill in the blanks.

In the above Scratch code, the when green flag clicked block is a part of the category, and it allows the program to
2 The say () for (2) seconds block in the Looks category displays a message that is displayed for seconds.
A Fill in the blanks.
1 Variable blocks are blocks that help a computer to a value.
2 The Make a Variable button is present in the category.
3 Use the block to make your sprite say something in Scratch.
4 The say block is found in the category of Scratch blocks.
B Tick () the correct option.
1 Which block is used to store a value?
a Mathematical block
c Variable block
2 In Scratch, how many types of variables are there?
a Three
c Two
b Ask block
d Addition block
b Four
d One

3 Which block is used to show the sprite?
a show b hide
c next costume d next backdrop
4 Which block is used to change the sprite’s costume to the specified one?
a think () for () seconds b swich costume to costume2
c next costume d next backdrop
C Who am I?
1 I am a block in Scratch that allows you to make your sprite say something.
2 I am used to store a number or text value.
3 I am used to change the sprite’s size by the amount.
4 I am used to change the stage backdrop to the specified one.
D Write T for True and F for False.
1 The say block is used to make a sprite move around the stage.
2 You can find the say block in the Events category.
3 A variable is changeable at any time.
4 The variable block is used to store operators.
E Answer the following questions.
1 What are Variables blocks?
2 How many types of variables can be created in Scratch?
3 What is the use of the Looks blocks category?
4 What is the purpose of using the block given below?

5 What is the difference between switch costume and next costume blocks?
F Apply your learning.
1 Divyansh is not aware of variables. Help him by telling him what variables are. Also tell him about the different types of values that can be stored in variables.
2 Open Scratch and create a bear sprite and a forest backdrop. Use this script to display the given message.

3 Think of a digital story that you would like to create in Scratch. How would you use both the Looks and the Variables blocks?

Using Operators, Sensing, and Control Blocks 3
In the previous chapter, we created the Score variable, and Pico sprite displayed the rules of the quiz using the Looks blocks.
Let us now learn some more blocks to proceed with our project.
Sensing Blocks
The Sensing blocks are used to sense conditions in the environment, such as the background colour or the sprite touching status. For example, you can use the touching color block to check if a sprite is touching a specific colour on the stage.
These blocks are cyan in colour and are used to detect various factors in a project. In Scratch, there are several categories of Sensing blocks that allow you to gather information about the environment and user input.
Let us now look at the usage of some of the Sensing blocks in the following table:
Blocks







Description
Determines if a sprite is touching a specific colour on the stage.
Checks if a sprite is currently touching another sprite or a colour.
Displays a message or a question for the user and waits for their input.
Retrieves the response given by the user to a previous ask and wait block.
Determines if a specific key on the keyboard is currently being pressed.
Resets the timer to zero, which can be used to measure the elapsed time.
Provides the time in seconds since the project started or since the reset timer block was used.
Using Ask and Answer Blocks
In our project, Pico will ask some questions using the ask and wait block. It then checks the answer given by the user through the answer block and accordingly it displays a message: “Yay! Right answer” or “Oops! Wrong answer”.
Follow these steps to proceed with the project.
1 Drag the say Hello! for 2 seconds block from the Looks category and join it to the existing say block.
2 Change “Hello!” to “Question 1”.
3 Add the ask and wait block from the Sensing category below the say block to ask the question, as shown here.

4 Add the say block from the Looks category to display answer.

Instead of giving a direct answer, let us add ‘Hello’ before displaying the answer using Operators blocks.

Operators Blocks
The Operators blocks are used to compare variables and values, perform calculations with numbers, and work with strings (text).
Mathematical Blocks
These blocks help a computer perform mathematical operations. They are found under the Operators block category.
The four most commonly used mathematical blocks are:
Blocks Name Description




Addition It is used to add two numbers.
Subtraction It is used to subtract a number from another number.
Multiplication It is used to multiply two numbers.
Division It is used to divide a number by another number.
Comparison Blocks
These are the blocks that help a computer make comparisons, depending on the statements or equations it checks.
Blocks Name



Description
Equal to It returns true when the two numbers are equal; it returns false when they are not equal.
Greater than It returns true when the first number is greater than the second; otherwise, it returns false.
Less than It returns true when the first number is less than the second; otherwise, it returns false.
More Operator Blocks
There are some more blocks that are very useful in projects.
Blocks


Name Description
Pick random number You can choose random numbers between the smallest and largest numbers (including those numbers).
Join This block is used for working with text strings. It combines two string values.
Let us continue our project using the join block to add hello before the answer.
1 Drag the join block from the Operators category to the blank section of the say block.
2 Replace apple with Hello and banana with answer block.
3 Let us type the question, “What is 239+354=?” inside the ask and wait block and join it with the say block.


Now, we have two conditions: if the answer is correct, it will display the message “Yay! Right answer” else, it will show, “Oops! Wrong answer”. Let us learn how to work with conditions using Control blocks.
Control Blocks
The blocks from the Control category allow a program to perform a test based on a given condition and then take actions based on the result of that test. Let us explore the usage of some of the blocks from the Control category.
Blocks Description








This block is used to check the given condition. If the condition is true, the blocks inside the if-then block are executed; if it is false, the blocks are not executed.
This block is an extension of the if-then block. If the given condition is true, then the blocks inside the if-then section are executed. If the condition is false, then the blocks inside the else part are executed.
The repeat block in the Control category repeats all the blocks inside it the number of times specified in the repeat block.
The forever block repeats the actions forever, never stopping until you click the red Stop button on the screen to end your program.
The repeat until block repeats the actions specified by the blocks inside it until a given condition is true. When the condition becomes false, the loop execution stops.
This block is used to wait for n number of seconds, where n is any integer.
The wait until undo pauses the script until the specified condition is true.
This block stops all the running scripts.

Follow the given steps to check whether the answer to the question is correct using the if-then-else block.
1 Drag the if-then-else block from the Control category to decide whether the response given by the user is correct or not.
2 Drag the equal to comparison block from the Operators category to the condition area of the if-then-else block.
3 Drag the answer block from the Sensing category to the left box of the equal to block.


4 Drag the Addition block from the Operators category to the right box of the equal to block and write the values as 239 + 354.
5 Click on the Looks category and then drag the say for 2 seconds block for the true condition of the if-then-else block, as shown.

6 This step ensures that Pico displays the result when the user provides the correct answer, as shown here.

Displaying the message when the condition is true.
7 Now, add one more say for 2 seconds block from the Looks category for the false condition under the else part and change “Hello” to “Oops! Wrong answer.” as shown here.

Displaying the message when the condition is false.
8 Click on the green flag button to test the script. When you click the green flag button, the Pico sprite asks the question and then waits for the answer from the user, as shown in the figure below.


9 Run the script and verify the conditions for the question.

Coding Challenge
Create a game in Scratch with the name ‘Colour Match’.


Objective: The player must click a sprite that matches a specific colour.
Instructions:
1 Create two sprites: a ‘Colour Matcher’ sprite and a ‘Colour Target’ sprite.
2 Create a script for the ‘Colour Matcher’ sprite to change its costume to a random colour when clicked using a Sensing block.
3 Create a script for the ‘Colour Target’ sprite to change its costume to a specific colour using a Sensing block.
4 Use Conditional blocks to check if the ‘Colour Matcher’ sprite’s costume matches the ‘Colour Target’ sprite’s costume.
5 If they match, display a message saying ‘You Win!’, using a say block.
6 If they do not match, display a message saying ‘Try Again’, using a say block.
7 Allow the player to click the ‘Colour Matcher’ sprite again to start a new round with a new random colour.
Do It Yourself 3A
Look at the following code and fill in the blanks.
1 In the given Scratch code, the wait () seconds block is a part of the category, and it allows the script to .
2 The say (Hello) for (1) seconds block in the category displays for seconds.

Chapter Checkup
A Fill in the blanks.
Hints User’s response add four decisions
1 The Control blocks in Scratch are primarily used to make in your program.
2 The ask and wait block is a block.
3 In Scratch, there are mainly types of mathematical blocks.
4 The Addition block is used to two numbers.
B Tick () the correct answer.
1 Which mathematical block is used to divide two numbers?




2 The subtraction block is present in the category. a Sensing
Operators c Motion d Variables

3 The block repeats the actions forever, never stopping until you click the red Stop button on the screen to end your program.
a Forever b repeat until c repeat d stop all
4 retrieves the response given by the user to a previous ask and wait block.
a touching b ask and wait c answer d key pressed
C Who am I?
1 I am a block in Scratch that allows you to ask a question to the user and then wait for their response before proceeding with the program.
2 I am used in Scratch to check if a specific condition is true or false and then make decisions based on the result.
3 I am a block in Scratch that waits for a certain period of time before allowing the program to continue.
4 I am a type of block in Scratch that helps you create loops and repeat actions.
D Write T for True and F for False.
1 A condition is applied to check a problem.
2 You cannot perform mathematical operations in Scratch.
3 Sensing blocks in Scratch are used to detect conditions associated with sprites and the stage.
4 The ask and wait block in Scratch allows you to ask a question on the screen and stores the keyboard input in the answer block.
E Answer the following questions.
1 What is the purpose of Control (Conditional) blocks in Scratch?
2 Explain the difference between the if and if-else Control blocks in Scratch.
3 What is the role of the ask and wait block in the Sensing category?
4 Describe the use of the following block.

F Apply your learning.
Complete the following length-finder game project.

Steps for making this length finder game are:
1 Drag the from the category to the script.

2 Drag the from the category and then initialise both x and y with 0.

3 Drag the block from the Sensing category to ask ‘Give me one word to find its length’ and then wait.
4 Add the block from the Variables category to set the word to answer.

5 Drag the block from the Sensing category to place it inside the block.

Sound Blocks 4
In the previous chapter we have learnt about the use of operators, sensing, and control blocks. Now, let us learn about Sound blocks before continuing with our project.
Sound Blocks
Sound blocks are used to control sound. There are nine Sound blocks in Scratch.
Some of them are:
Did You Know?
The first animated film, ‘Steamboat Willie’, featured only background music and no spoken dialogue.
Blocks Description






Plays a sound and pauses the script until the sound is finished.
Plays a sound without pausing the script.
Stops all playing sounds.
Clears any currently active sound effects.
Changes the volume by the specified amount.
Sets the volume to the specified amount.
The aim of our project is that if the answer is correct, the score will increase by 10 points, and a clapping sound will play. Else, the score will remain the same, and a losing sound will play.
Discuss
How do the sound blocks make your project feel different?
Finalising the Project
Now, we have to set the condition under the if block, if the answer is correct.
1 Drag the Change my variable by block from the Variables category and join it under the say block in the if section of the if-then-else block.
2 Change My variable to Score and the value 0 to 10.

3 Now, drag the play sound block from the Sound category and join it to the change score to block.
4 Now, click the Sounds tab.
5 Click on the Choose a Sound option. The Sound Library opens.

6 Type Clap in the search box. Click on the Clapping sound to add it to the project.


7 The sound is added.

8 Click on the Code tab.
9 Change the sound to Clapping in the play sound until done block.

10 Click on the Go button to test your project.
Now, let us set the condition under the else block, if the answer is not correct.
1 Drag the Change my variable by block from the Variables category and join it under the say block in the if section of the if-then-else block.
2 Change the value of My variable to Score and the value to 0.

3 Now, drag the play sound block from the Sound category and join it to the change score to block.
4 Now, add the sound Lose in the play sound block by following the same steps you used for adding the clapping sound previously.

5 Click on the Go button to test your project. We have set all the conditions for both scenarios, either the right answer or the wrong answer. Repeat the same steps to add the other questions to the project. However, this will take a lot of time. Let us explore a shorter way to do it.
Duplicating the Script
Follow the given steps to duplicate a script.
1 Drag the say Hello! for 2 seconds block from the Looks category and join it to the if-thenelse block.
2 Change “Hello!” with “Question 2”.
3 Add the ask and wait block from the Sensing category below the say block to ask the question “What is 12 × 5 = ?” as shown here.


4 Right-click on the if-then-else block.
5 Select the Duplicate option to copy the code.

6 Change the Operator block and its value as per the given question.

7 Your project is complete. You can add more questions to your project by using subtraction, division, and other operators to make your project interactive.
Coding Challenge
Help Dino avoid obstacles to achieve a high score.

Do It Yourself 4A
Match the following.




A sound in the Sound Pane.
Make a sprite say something for the specified amount of time.
Play a sound until it completes.
Add a new sound.

Chapter Checkup
A Fill in the blanks.
Hints
start sound Choose a Sound Sensing Sound
1 The blocks plays a sound without pausing the script.
2 The play sound block is located in the category of blocks.
3 You can add the ask and wait block from the category.
4 To open the Sound Library, option is selected.
B Tick () the correct option.
1 There are sound blocks. a Five b Seven c Nine d Ten
2 Which block is used to add sound to your Scratch project?




3 Which category of Scratch blocks does the play sound block belong to?
a Motion
b Looks
c Sound d Events
4 The play sound block is used to:
a Control the sprite’s size.
c Add music or sound effects.
b Make the sprite disappear.
d Change the sprite’s costume.
C Who am I?
1 I help you add sound for your projects in Scratch.
2 I help you set the volume to the specified amount.
3 I am used to change the sound.
4 I am an option used to duplicate a sprite.
D Write T for True and F for False.
1 The play sound block is used to change the colour of your sprite.
2 You cannot change the sound once it is added in a project.
3 You can add only one if-then-else block to a project.
4 You can duplicate a script.
E Answer the following questions.
1 What are sound blocks?
2 Name any five sound blocks.
3 What does the play sound block do?
4 How can you duplicate a script?

F Apply your learning.
Complete the following Clicker Game Project.

Steps for making this clicker game are:
1 Drag the block from the category to the script area.

2 Add the block from the category.

3 Drag the block from the Motion category to move the balloon in a random direction.
4 Add the block for the 2 seconds block from the Control category.
5 Drag the block from the category to add in the script.

6 Add the block from the Sound category to make the sound when the sprite gets clicked.
7 Now, add the block from the Variables category to change the score by 1 whenever the player clicks the sprite.




AI Project
What is Artificial Intelligence (AI)?
Artificial Intelligence, or AI, is a technology that helps computers learn from data and follow instructions to solve problems and make decisions. AI programs use patterns and examples to work. It is used in voice assistants, robots, and smart apps to help with many tasks. AI is becoming a big part of how we use technology every day.
Project: Video Sensing
Objective: In the Scratch video sensing project, AI is used to help the computer recognise and respond to movements or changes detected by the camera. The AI processes the video input to identify when something moves or appears in front of the camera. By analysing this data, the project can trigger actions, such as making a character move or play a sound, based on what the computer “sees.” Let us create the project in Scratch.
1 Open Scratch and create a new project.
2 Delete the default cat sprite by clicking on the Delete button.
3 Now, add a sprite by clicking the Choose a Sprite option in the Sprites pane.
4 Select the Balloon1 sprite from the Sprite Library.
5 Click the Add Extension button.

6 The Extension Library opens. Choose the Video Sensing category.

7 The Video Sensing extension is added to the blocks panel. These blocks use your webcam.

4 Scroll down to check the created images.
5 Click on the image you like the most.
8 Now, drag and drop the when video motion block to the script area. This block works best with the default value 10.
6 Download the image by clicking the Download button given below the image.
9 Drag and drop the play sound Pop until done block from the Sound category. This block plays the pop sound, by default.

10 Drag and drop the change color effect by block from the Looks category.
11 Drag and drop the go to random position block from the Motion category.
12 Your final code will look like the one below.

7 Open MS Paint and paste the image if possible, or try redrawing it using shapes and colours as shown in the chapter.

13 You can pop the balloon shown on your webcam by touching it with your finger.

A. Fill in the blanks.
1 is the process of creating sets of instructions that a computer can understand and execute.
2 The next costume block is present in the block category.
3 blocks are used to combine two strings.
4 block plays a sound without pausing the script.
B. Tick () the correct option.
1 is the area where sprites interact and display the results of your code.
a Sprite b Stage
c Tabs d Backdrop
2 block is used to show the sprite.
a next costume b next backdrop
c show d hide
3 blocks help a computer make comparisons, depending on the statements it checks.
a Comparison b Mathematical
c Variable d Sensing
C. Write T for True and F for False.
1 The green flag button is used to run your project.
2 A variable can contain five types of values.
3 Mathematical blocks help a computer perform mathematical operations.
4 Control blocks are used to create loops and repeat actions.
D. Answer the following questions.
1 Define coding area.

2 What are variable blocks?
3 What is the use of pick random number block?
E. Apply your learning.
1 Akshit has made an amazing design in Scratch but doesn’t know how to duplicate a sprite. What should he do?
2 Ana has designed a character in Scratch but doesn’t know how to animate a sprite. What should she do?
3 Rohit created an animation in Scratch but isn’t sure how to add sound effects. What should he do?
About the Book
This coding book is supplementary to the main Tekie.AI content book. It represents a 21st-century approach to learning coding concepts and developing computational thinking and problemsolving skills. To prepare students for the digital age, the curriculum is interwoven with well-thought-out concept progression, real-life examples, and practice problems. This book stands out with the integration of Artificial Intelligence, enabling students to use AI in projects and turn their ideas into real-world creations.
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.
• AI Projects: To transform coding concepts into powerful simulations of real-world intelligence.
• 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-992716-8-5
