Saturday, 30 December 2023

L-8 Scratch / Class 8th Computer

Class – VIII

Subject: Computer

L-8 Scratch Programming II- Variables, Control, Actions


A.) Fill in the blanks using the words from the help box:

[tempo  , record new sound, commands,   volume,    Boolean block, block, variable ]

 

1)    Scratch provides all types of  commands  as  blocks that can be stacked to form a program or script.

2)    The loudness of a sound is called its  volume, and the speed at which a sound plays is called its tempo.

3)    A  variable  is a placeholder that can hold / store a value as long as your scripts runs.

4)    To record a new sound click on the  record a new sound  button.

5)    The condition is defined via a  Boolean block .

 

B) State ‘T’ for True or ‘F’ False:

1) In scratch, movement of a sprite draws on stage only if pen is down. FALSE

2) A variable is named storage location which holds a value as long as the script runs._TRUE

3) Multiple sprites can receive a message. TRUE

4) You can record a new sound on Scratch. TRUE

5) Green flag is located at the top right corner of the stage._ FALSE

 

C) Multiple Choice Question:

1) Which block menu has the blocks to show or hide a sprite from the stage?

a) Pen

b) Motion

c) Looks

 

Ans: c) Looks

 

2) Which tab is used to add a new sound on the stage.

a) Music

b) Sounds

c) Costumes

 

Ans: b) Sounds

 

3) Which of the following are conditional block.

a) If-else

b) Repeat

c) Forever

 

Ans: a) If-else

 

4) These blocks are repeat, repeat until, forever.

a)  Loop block

b)  Stack block

c)  Selection block

 

Ans: a) Loop block

 

5) The type variable described for only one sprite.

a)  Global

b)  Cloud

c)  Local

 

Ans: c) Local

 

 

d) Answer the following  questions:

 

1) What are variables in scratch?

Ans:  Variables in Scratch are placeholders that store and hold values. They allow the program to remember and manipulate data as the script runs.

 

2) What are the different kinds of variables provided by the scratch? Explain.

Ans:  Scratch provides two main types of variables:

Local Variables: These are specific to a sprite and can only be used by that sprite.

Global Variables: These are shared among all sprites in a project.

 

3) What are Events in scratch? How are these useful.

Ans:  Events in Scratch are actions or occurrences that trigger specific blocks of code. Examples include the green flag clicked, key pressed, or sprite clicked. Events make programs interactive and responsive to user actions.

 

4) Explain the process of adding new sound from the sound library.

Ans:  To add a new sound from the sound library in Scratch, click on the "Choose a Sound" button, then select the desired sound from the library. After selecting, click on the "OK" button to add the sound to the project.

 

5) What is the difference between if and if-else block?

Ans:  The if block checks a condition and executes a set of statements if the condition is true. The if-else block also checks a condition but has an alternative set of statements to execute if the condition is false.

 

6) What is the difference between repeat, repeat until and forever block?

Ans: The repeat block repeats a set of statements for a specified number of times. The repeat until block repeats a set of statements until a specified condition becomes true. The forever block repeats a set of statements indefinitely.

 

Lab Activity:

1)    Open scratch and add any Sprite of your choice on the stage. Create a script and perform the following activities:

a)    Move towards east and then make a circle.

Ans: 1) when green flag clicked

go to x: (-240) y: 0   // Assuming starting point is at the center of the stage

point in direction 90  // Pointing towards east

repeat 36

  move 10 steps

  turn 10 degrees

end

 

b)    Speak something on the stage.

Ans: when green flag clicked

say "Hello, Scratch!" for 2 seconds

 

c)    Add some music in your project.

Ans: when green flag clicked

play sound [your_music.mp3]  // Replace with the name of your music file

 

2)    Draw a flower in scratch.

Ans: when green flag clicked

repeat 36

  // Draw a petal

  forward 50

  right 45

  forward 50

  right 135

  forward 50

  right 45

  forward 50

  // Move to draw the next petal

  right 10

end

 

 

3)    Write a scratch program to draw this.

Ans: when green flag clicked

// Assuming the desired shape is a square

repeat 4

  forward 100

  turn 90 degrees

end

 

Critical thinking:

1)    How to write an interactive program in which a sprite is crazily drawing on stage forever, but if the user presses spacebar, the pen size and the pen color change along with a sound play.

Ans: pen size variable [size]

when green flag clicked

forever

  // Check if space key is pressed

  if key [space v] pressed?

    // Change pen size and color

    set pen size to (size)

    set pen color to [random color]

    // Play sound

    play sound [your_sound.mp3]

  end

  // Crazily draw on stage

  move (10) steps

  turn (15) degrees

  change size by (1)

end

 

2)    Charvi is playing a game created by her teacher using Scratch. The game works like this:

An item/ thing name is shown on screen and then the screen shows moving images of multiple things/ sprites. The player has to click on correct image / sprite as per displayed name. If the player clicks on correct sprite / image, a ball sprite in the right corner starts jumping and clap sound also plays. If the player wants to move to next thing/ item, the player can press a spacebar.

Ans: when green flag clicked

forever

  // Show item/thing name on screen

  say [item_name] for (2) seconds

  // Show moving images of multiple things/sprites

  // (Code logic for displaying moving images)

  // Wait for player's click

  wait until <mouse down?>

  // Check if correct sprite/image is clicked

  if touching [correct_sprite v]?

    // Ball sprite jumps

    repeat (3)

      jump (20) steps

      wait (0.2) seconds

    end

    // Clap sound plays

    play sound [clap.mp3]

  end

  // Wait for spacebar press to move to the next thing/item

  wait until <key [space v] pressed?>

end

 

Group Discussion:

1)    Discuss the different methods to add sounds in a project. Create a loop structure and discuss how to create a pattern and apply sounds while pressing key.

Draw a picture based on the above group discussion.

Ans: Discussion Points:

 

Using the "play sound" block to add sounds.

Utilizing the "when key pressed" event for key interactions.

Creating a loop structure to repeat sound patterns.

Discussing how to synchronize sound with other actions in the project.


No comments:

Post a Comment

L-1 Indian Heroes in IT/ 8th computer

  Class 8 th Subject : Computer Science L-1 Indian Heroes in IT Make a list of Indian Heroes in IT with their achievement S....