Computer Notes 8th Class Unit No.6

UNIT NO.6

Programming

(Solved Exercise)

C. Name the Category that Perform the Following Action
1. Used for moving sprites around the stage.
Motion

2. Used for animating sprites, giving them speech bubbles, and changing their size and appearance.
Looks

3. Used for playing recordings or musical notes.
Sound

4. Used to describe what happens when, and for making bits of your program repeat.
Control

5. Used to test whether your sprite is touching another sprite or another color, or to get information about other sprites.
Sensing

6. Used for Maths random numbers, and doing things to text.
Operators

D. Answer the following questions:
1.Explain the difference between programming and program.
Programming
Programming is the art of writing instructions to tell a computer what to do.
Program
A set of instructions is called program.

2.Why is Scratch considered to be a good programming language for animation, games and storytelling?
Scratch considered to be a good programming language for animation, games and storytelling because Scratch enables you to quickly see results from work, and even includes graphics and sounds. The commands are colour-coded and categorised, so it is -easy to find a command when required.

3.Explain the usage of the events and control category.
Events: Event category is used to make the sprite perform according to the event done for example when the Green flag is clicked.
Control: Control category is used to describe what happens when, and for making bits of your program repeat. This block is used to manage scripts in specific conditions. For example repeat, forever, etc.

4.What are variables?
In programming, a variable is a place for some value in memory, much like x and y are popular variables in algebra. In Scratch, variables are represented with blocks shaped like elongated circles, uniquely labelled by you.

5.What are boolean expressions? How can you identify them?
A Boolean expression is an expression that is either true or false. In Scratch, any block shaped like an elongated diamond is a Boolean expression.

6.Can we have more than one backdrop in our program? If yes, then how to create them and change the backdrop?
Yes, we can have multiple backdrops in our program. To create click “Choose a Backdrop” from stage section and use the “switch backdrop to” block to change between them during the program.

7.What are the three main block for cloning in Scratch? Explain them in two lines.
In Scratch, the three main blocks for cloning are:
I. Create Clone of [ ]: Generates a duplicate (clone) of the specified sprite during the program.
II. When I Start as a Clone: Runs the code for the clone when it is created.
III. Delete This Clone: Removes the clone to free memory or manage game mechanics.

8.Explain any five different categories of blocks.
Motion: This category is used for moving sprites around the stage, for example, move, turn, etc.
Looks: This category is used for animating sprites, giving them speech bubbles, and changing their size and appearance, for example, say, think, etc.
Sound: This category is used to regulate sound function and playing recordings or musical notes. They are colour-coded pink/magenta. For example, play sound, stop all sound, etc.
Events: This category is used to make the sprite perform according to the event done, for example when the Green flag is clicked.
Control: This category is used to describe what happens when, and for making bits of your program repeat. This block is used to manage scripts in specific conditions. For example repeat, forever, etc.

9.What are some of the limits of Scratch?
Some limits of Scratch include:

  • Simple programming: Scratch is good for simple games and animations but not for advanced programs.
  • Limited performance: Large projects may run slowly or crash.
  • No real-world apps : You can’t make mobile apps or websites directly with Scratch.

10. What does this block of code do?

Answer: This script makes the sprite change to a specific costume, set its size to 100% of its default size, turn slightly, move forward, and bounce off the edges of the screen if it reaches them.

E. Answer the following questions:

1. Explain loops with examples.
Loops
A loop in programming can execute statements several times depending on a condition. In Scratch, any block whose label begins with ‘forever’ or ‘repeat’ is a looping construct.
One such block is:

For example, with this construct, we may tell a sprite to say ‘Hello!’. If the project is running or the Stop button is not pushed, the instructions contained in the forever block continue to be executed forever. This is very helpful for things like making background music or other actions that you do not want to stop.

Another block allows you to play a loop a specific number of times. This loop would be used to repeat an activity, for example, four times if we knew we intended to perform that task four times. This greatly reduces the overall length of the code and helps to prevent minor errors.

Another block allows you to play a loop until some condition is true. A loop and a condition in the ‘repeat until’ block. Depending on the situation, you might not always be able to predict how often you want a certain action to occur. This block determines whether a condition is met at the beginning of each loop, and if it is, it stops running.

2. Write a note on any four elements in programming.

Variables:

In programming, a variable is a place for some value in Memory, much like x and y are popular variables in algebra. In Scratch, variables are represented with blocks shaped like elongated circles, uniquely labelled by you.

Statements
In programming, a statement is simply a directive that allows the computer to do something. It can be thought of as a command or an instruction. In Scratch, any block whose label is read like a command is a statement.

One such block instructs a sprite to say something.

Boolean Expressions

In programming, a Boolean expression is an expression that is either true or false. In Scratch, any block shaped like an elongated diamond is a Boolean expression.

Conditional Statements
Statements with a condition and a result are said to be conditional. Depending on whether a condition is true or false, a conditional statement instructs a program to act.