Excercise No: 6- Creation of Functional Blocks for Simple Mathematical Problems
Title:
Creation of Functional Block for Simple Mathematical Problems using Scratch Programming
Aim:
To create and use functional blocks in Scratch to solve simple mathematical problems such as addition,
subtraction, multiplication, and division.
Software Used:
Scratch Programming Environment
Algorithm / Procedure:
1. Open the Scratch programming environment.
2. Create a new project and delete the default sprite if necessary.
3. Click on “My Blocks” and then click “Make a Block”.
4. Name the block (e.g., AddNumbers, MultiplyNumbers, etc.).
5. Add input parameters (e.g., num1, num2).
6. In the definition area, add appropriate arithmetic blocks to perform the mathematical operation.
7. Create separate functional blocks for:
o Addition
o Subtraction
o Multiplication
o Division
8. Use the created blocks inside the main program to compute results.
9. Display the results using the “say” or “show variable” block.
Addition:
Subtraction:
Factorial :
Result:
Functional blocks were created and executed successfully for performing simple mathematical
operations in Scratch.
[Link].7:Drawing and Painting Operations using Scratch Programming
Aim:
To perform drawing and painting operations in Scratch using pen blocks and sprite movement.
Algorithm / Procedure:
1. Open the Scratch environment and start a new project.
2. Add the Pen Extension from the “Extensions” menu.
3. Choose a sprite (or use the default cat sprite).
4. Use the pen down block to start drawing.
5. Use move ( ) and turn ( ) blocks to make the sprite draw shapes.
6. Change pen color and size using the respective blocks.
7. Use pen up when you want to move the sprite without drawing.
8. Experiment with loops (repeat, forever) to draw patterns.
9. Run the script to observe the drawing or painting created.
Drawing a Square:
1. when green flag clicked
2. erase all
3. pen down
4. repeat 4
5. move 100 steps
6. turn 90 degrees
7. end
8. pen up
Drawing a Circle:
[Link] green flag clicked
[Link] all
[Link] down
[Link] 36
[Link] 10 steps
[Link] 10 degrees
[Link]
[Link] up
Painting
1. when green flag clicked
2. erase all
3. pen down
4. set pen color to
5. change pen size by 100
6. repeat 4
7. move 100 steps
8. turn 90 degrees
9. end
10. pen up
Result:
Drawing and painting operations were successfully implemented in Scratch using pen extension and
motion blocks.
[Link].9:Drawing Artistic and Geometric Patterns and Creating Simple Games
using Scratch Programming
Aim:
To use Scratch programming to design artistic and geometric patterns and to create simple interactive
games.
Algorithm / Procedure:
1. Open Scratch and start a new project.
2. Add the Pen Extension.
3. Clear the stage and set the pen color and size.
4. Use pen down to start drawing.
5. Use motion and control (repeat) blocks to draw geometric shapes such as squares, triangles,
circles, or spirals.
6. Use loops creatively to form artistic designs.
7. Click the green flag to view the pattern.
Example Program (Geometric Star Pattern):
when green flag clicked
eraseall
pen down
set pen color to [#ff0000]
repeat 36
move 100 steps
turn 170 degrees
end
pen up
(B) Creating a Simple Game
1. Create or choose a sprite (e.g., ball, paddle, or character).
2. Add background and define rules for movement.
3. Use keyboard event blocks to control sprite movement.
4. Add conditional statements to detect collision or boundaries.
5. Use variables to keep track of score or lives.
6. Include sound and visual feedback for interaction.
7. Run the game and test user interaction.
Example Program (Simple Ball Bounce Game):
Result:
Artistic and geometric patterns and a simple interactive game were successfully created using Scratch
programming.