Loading...
Please wait while we prepare your content
Please wait while we prepare your content
Solutions for Computer Applications, Class 9, CBSE
Carefully go through some sample scripts given below. What is happening in each of these scripts ?
Script 1
When the sprite is clicked, it will repeatedly move 5 steps in the direction it's facing. If it reaches the edge of the screen, it will bounce back and continue to move 5 steps infinitely.
Script 2
When the sprite is clicked, it will repeatedly move 5 steps in the direction it's facing. If it reaches the edge of the screen, it will bounce back and it will also gradually rotate clockwise if it's facing right, or anticlockwise if it's facing left.
Script 3
When the green flag is clicked, the sprite will face to the right, resize to 60% of its original size and move to the position with coordinates (-100, -70). It will check if it's touching another sprite named "Sprite1". If it is, it will display the text "Woof!" in a speech bubble for 2 seconds.
How are following two scripts different from one another ?
The key distinction between the given scripts is that in the first script, the "Woof!" message will be displayed once when the sprite is touching "Sprite1". In the second script, because of the forever loop, the "Woof!" message will be repeatedly displayed every time the sprite is touching "Sprite1", as long as the program is running.
Create a fun game in scratch where there are two sprites on the stage cat sprite and a ball sprite. Ball is forever moving on stage. The cat sprite's movement is controlled by pressing all arrow keys : up/down/left/right. If the cat sprite touched the ball sprite, it exclaims "Hurray!!".
Below is the scratch script for the game:
Write a script/program to draw a heptagon on the stage.
Below is the scratch script to draw a heptagon on the stage:
Write a script/program to draw an Octagon on the stage.
Below is the scratch script to draw an octagon on the stage:
Using drawing commands, carefully design a script to draw the adjacent figure on the stage.
Below is the scratch script to draw the house on the stage:
In which block category do you find blocks to start your script ?
Events
Reason — Hat blocks are used to start a script and are usually found in Events category of blocks.
In which category do you find block to change the direction of sprite ?
Motion
Reason — Motion category of blocks contains blocks for the movement of a sprite.
The background on which your script runs or your sprite moves, is called ............... .
The stage
Reason — The background on which your script runs or your sprite moves, is called the stage.
The background imagery of the stage is known as ............... .
Backdrop
Reason — The background imagery of the stage is known as backdrop.
Which of the following command will leave impression of sprite on the stage ?
Stamp
Reason — Stamp command leaves an impression of sprite on the stage.
Which of the following command will prevent your sprite to move off the stage ?
If On edge, bounce
Reason — If On edge, bounce command checks to see if the sprite is on the edge of the stage. If the sprite is on the edge, then it flips the sprite around so that it faces the other way. Thus, the sprite cannot get off the stage.
Which of the following will take action based on an action only once ?
if <condition> then
Reason — The if <condition> then block takes an action depending on a certain condition.
From the given table of letters, find words / terms related to Scratch (can be left-to-right, right-to-left, top-to-bottom, diagonally upwards, downwards etc.)
The words are as follows:
Look at the section of code opposite that controls a sprite.
Write down what you think the user will see when the green flag is clicked.
When the green flag is clicked, the sprite is at the same position.
Why did you think the sprite behaved this way ? (refer to above question)
The sprite behaved this way because the sprite moved forward 10 steps and then moved backwards the same number of steps.
A position on the stage is also called ................ .
pixel
Reason — A position on the stage is also called pixel.
Name the block to replay an action (or a set of actions) for a specific number of times
repeat block
Reason — The repeat block is used to repeat a code a specific number of times.
Name the block to keep repeating a set of action endlessly
forever block
Reason — The forever block is used to keep repeating a set of action endlessly.
Name the block used to perform an action or a set of actions only if some condition is true or another action has happened first
if
Reason — The if block is used to perform an action or a set of actions only if some condition is true or another action has happened first.
The location of the sprite on the stage can be controlled via
the "x" and "y" coordinates
Reason — The location of the sprite on the stage can be controlled via the "x" and "y" coordinates.
Match the following statements
(i) Group of commands that together make a sprite behave in a certain way | (a) Motion Blocks |
(ii) Blocks used for drawing on the stage. | (b) Stage |
(iii) Background on which animations and other actions take place. | (c) Script |
(iv) Category of blocks that mostly begin the working of script. | (d) Hat blocks |
(v) Category of blocks that let you specify the direction for sprite. | (e) Pen blocks |
(i) Group of commands that together make a sprite behave in a certain way | (c) Script |
(ii) Blocks used for drawing on the stage. | (e) Pen blocks |
(iii) Background on which animations and other actions take place. | (b) Stage |
(iv) Category of blocks that mostly begin the working of script. | (d) Hat blocks |
(v) Category of blocks that let you specify the direction for sprite. | (a) Motion Blocks |
The following block is an example of a(n) ................. .
Loop
Reason — The following block is an example of a loop.
What is program ? What is programming ?
Program refers to a set of instructions given to computer to do something. For example, to add two numbers.
Programming refers to the act of writing programs.
What do you understand by these terms ?
(a) Stage
(b) Sprite
(c) Blocks Palette
(a) Stage — Stage is the background on which animations and other actions take place.
(b) Sprite — A sprite is a graphic image, usually animated, that a user can interact with and that moves around.
(c) Blocks Palette — Blocks Palette is the area that contains all possible types of commands. It groups the commands in various categories such as Motion, Looks, Sound, Pen, Events etc.
What does a script or a program do in Scratch ?
In Scratch, a script is a sequence of visually stacked blocks that control a sprite's actions. These blocks, representing commands like movement and sound, are dragged and connected to create instructions. When the program runs, the sprite follows the scripted actions. We can control the movement, appearance, sound, and interactions of sprites through these scripts.
What are the values for four main directions in Scratch ?
The values for four main directions in Scratch are as follows:
State true or false.
(a) Control category contains blocks that start or stop a script.
(b) You can even load own sprite from a file.
(c) You can grow a sprite but cannot shrink it.
(d) Pen down command stops the drawing on the stage.
(e) Backdrops are the backgrounds for the stage.
(a) True
Reason — The Control category or Events category in Scratch contains blocks like "when green flag clicked" to start a script and "stop" blocks to halt the script's execution.
(b) True
Reason — In Scratch, we can import our own sprite images from files to use in our projects, enhancing customization.
(c) False
Reason — In Scratch, you can both grow and shrink a sprite using the "change size" block in the Looks category.
(d) False
Reason — The "pen down" command in Scratch actually starts the sprite drawing on the stage, allowing it to leave a trail behind as it moves.
(e) True
Reason — The background that we see on the stage is the backdrop.
Look at the section of code below that controls a sprite.
Write down what you think the user will see when the green flag is clicked.
First section of code — When the green flag is clicked, the sprite will move 10 steps towards the right direction.
Second section of code — When the green flag is clicked, the sprite will move 10 steps towards the left direction.
In the stack of blocks below, how many times does the sprite move 10 steps?
Eight times.
What is the job of the 'forever' script ?
The forever block repeats a set of actions forever. For example,
when green flag clicked
forever
move 100 steps
if on edge, bounce
What instructions would I use if I wanted a loop to execute 10 times ?
I would use the command repeat 10 if I wanted a loop to execute 10 times.
What is a loop ?
A loop is a conditional statement that needs to be directed for it to work
Reason — The blocks that let us repeat a certain action or a group of actions are called loop blocks. For example, repeat, forever and repeat until are loop blocks.
What is an infinite loop or continuous loop ?
A never ending loop is known as an infinite loop or continuous loop. The forever command creates an infinite loop in Scratch.
What is an if-statement ? Give two examples.
The if block from Controls category is used when we have to take an action depending upon a certain condition. It allows a program to execute certain actions only if a specific condition is true. If the condition is false, the actions within the if-statement are skipped.
Consider the following examples:
1. If we want our sprite to move to the center of the stage when it touches the edge of stage, we can use the given script:
if touching edge then
go to x : 0 y : 0
2. If we want our sprite to say "You win" when it touches another sprite (ball), we can use the given script:
if touching ball then
say "You win"