Alt Class – Introduction to narrative algorithms using a full example
See the example below
Problem: Create a solution to find the area of a circle.
Problem Definition: Create a program which prompts the user to enter the radius of a circle, and outputs its area.
Algorithm in narrative form:
1. Welcome the user and proceed to prompt the user to enter the radius of the circle.
2. Store the entered radius in a variable.
3. Use the formula for the area of a circle: Area = π × radius² (where π is approximately 3.14159).
4. Calculate the area by squaring the radius and multiplying the result by π.
5. Output the calculated area of the circle to the user.
6. End the program with a thank you message.
Algorithm in Pseudocode:
START
R ← 0
AREA ← 0
pi ← 3.14159
OUTPUT "Welcome to the Area of a Circle Calculator"
OUTPUT "Please enter the radius of the circle:"
INPUT R
AREA ← pi * (R * R)
OUTPUT "The area of the circle is: ", AREA
OUTPUT "Thank you for using the calculator!"
STOP
See Flowgorithm File And flowchart graphic here: https://drive.google.com/drive/folders/1Lbf_A-SdV5F4P1YEFui1scGLc3FGVFG1?usp=sharing
© 2024 Vedesh Kungebeharry. All rights reserved.
Assignment – Creating a 4 Scene Scratch Animation Using A Storyboard
- Storyboard Creation:
- Create a storyboard with at least 4 scenes or backgrounds.
- Include two characters speaking at least a total of 4 sentences per scene.
- Incorporate at least 2 animations across the four scenes.
- Storyboard Development:
- Begin with rough sketches in your notebook during class with guidance from your teacher.
- Finalize the storyboard in your notebook with:
- One column for the visual description of the scene (drawing).
- Another column for the text narration, including character positioning and animation.
- Scratch Project Implementation:
- Create a shared Scratch project based on your storyboard.
Submission Requirements:
- Your completed storyboard must be drawn in your ICT notebook. Submit visible screenshots of your notebook either as a series of images or within a PDF document.
- Include a link to your shared Scratch project. (See here for sharing a Scratch project: How to Share a Scratch Project)
- If working in a group, only the group leader needs to submit the above. Include the names of all other group members.
Rubric
| Criteria | Marks | Description |
| Storyboard Visuals | 5 | |
| 5 | All four scenes are clearly sketched with detailed visual descriptions. Each scene includes backgrounds, characters, and important objects. | |
| 4 | Three scenes are clearly sketched with detailed visual descriptions. One scene may lack minor details. | |
| 3 | Two scenes are clearly sketched with detailed visual descriptions. Two scenes may lack minor details. | |
| 2 | One scene is clearly sketched with detailed visual descriptions. Three scenes lack details. | |
| 1 | Minimal effort in sketching. Most scenes lack details. | |
| 0 | No visual descriptions provided. | |
| Character Positioning & Text Narration | 5 | |
| 5 | Each scene includes clear positioning of characters with accurate text narration of at least 4 sentences per scene. Dialogues are coherent and contribute to the story. | |
| 4 | Each scene includes clear positioning of characters with accurate text narration of at least 3 sentences per scene. Dialogues are mostly coherent. | |
| 3 | Each scene includes clear positioning of characters with accurate text narration of at least 2 sentences per scene. Dialogues are partially coherent. | |
| 2 | Scenes have characters and text narration, but positioning is unclear or text is less than 2 sentences per scene. | |
| 1 | Minimal effort in character positioning and text narration. | |
| 0 | No character positioning or text narration provided. | |
| Animation Description | 3 | |
| 3 | Two animations are clearly described across the four scenes, including details on how and when they occur. | |
| 2 | Two animations are mentioned but lack detail on how and when they occur. | |
| 1 | One animation is described with some detail. | |
| 0 | No animations described. | |
| Implementation in Scratch | 2 | |
| 2 | The Scratch project closely follows the storyboard, with all scenes, dialogues, and animations accurately implemented. | |
| 1 | The Scratch project follows the storyboard with minor deviations. Most scenes, dialogues, and animations are accurately implemented. | |
| 0 | The Scratch project does not follow the storyboard or is not implemented. | |
| Creativity & Coherence | 1 | |
| 1 | The story is creative, coherent, and engaging. It shows originality and thoughtful integration of elements. | |
| 0 | The story lacks creativity, coherence, or engagement. It appears rushed or poorly thought out. | |
| Total | 15 |
© 2024 Vedesh Kungebeharry. All rights reserved.
Scratch: Creating a New Sprite [External Resource]
Practice the tutorial shown here:
Optional Tutorials:
A Slanted Rectangle – Revision Exercise
Create a scratch Script/Program which uses the pen tool to draw a rectangle
slanted at a 45 degree angle. Ensure that the rectangle occupies a large portion of the stage.
Submit a link to you scratch project for marking
1 – When Green flag is clicked
1 – Immediately erasing all pen activity before drawing the rectangle
2 – orienting the pen to 45 degrees
2 – Correct use of a loop
2 – correctly drawing the length
2 – correctly drawing width
2 – correct use of the turn block
3 – Good positioning of the rectangle withing the stage
© 2024 Vedesh Kungebeharry. All rights reserved.
A Slanted Rectangle – Solution
Scratch Project: https://scratch.mit.edu/projects/999695955/editor/
See video below:
© 2024 Vedesh Kungebeharry. All rights reserved.
Algorithm Solution: Using Computational Thinking to solve a Math problem
This is the solution and feedback for the problem blogged@ https://islandclass.wordpress.com/2018/05/25/using-computational-thinking-to-solve-a-math-problem/
Solution
Algorithm:
1. Start
2. Start with N numbers
3. Determine the number of pairs, p = N/2
4. Find the sum of the first and last number , AL= Fn+Ln
5. Calculate sum, Sum = p* AL
6. Present the Sum.
7. Stop
© 2024 Vedesh Kungebeharry. All rights reserved.
CSEC 2023-24 SBA – Spreadsheet Mark Assignment
Group 1
Group 2
Group 3
Full marks awarded, feedback video recording of class failed.
Group 4
Group 5
Linkers
Continuing from our previous example, The linker can now takes over, it searches for the actual object code implementation containing scanf and printf, (along with any other dependencies), and combines it with the original main.o code from the example above.
In combining the object files, the references are resolved so that scanf and printf implementation can be accessed by the main.o machine code in the same way that find_sum can be accessed from the original object code file. The result is a stand alone executable file which is essentially our program.
In summary, Linkers combine the generated object code from the translation process to other dependencies or references needed to execute the program, it converts reference placeholders to actual addresses, thus linking the main program to its dependencies to create fully functioning executable code.
© 2024 Vedesh Kungebeharry. All rights reserved.
Code Generation (Object Code)
The optimized TAC is now used to generate assembly code.
The assembly code is converted into object code in a process known as assembly.
This object code contains machine instructions corresponding to the source code, but may not be fully functional for execution as yet.
Consider the following example in source code in a file “main.c” :
#include <stdio.h>
//function prototype omitted for simplicity
int find_sum(int num1, int num2) {
return num1 + num2;
}
int main() {
int num1, num2;
printf("Enter the first number: ");
scanf("%d", &num1);
printf("Enter the second number: ");
scanf("%d", &num2);
int result = find_sum(num1, num2);
printf("The sum of %d and %d is %d\n", num1, num2, result);
return 0;
}
The machine code for the main and find_sum function is generated, and stored in the object file, main.o . Since scanf and printf is used but exist in other libraries, the compiler creates code know as references (placeholders) to call scanf and printf, but doesn’t include the implementation of of scanf and printf in in the main.o object file. The creation of main.o was the final step of the code generation.
Now we move on to the last phase to use a linkers combine various bits of object code to create one executable file.
© 2024 Vedesh Kungebeharry. All rights reserved.