Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 36

UNEMI DAmc-NAm CeacIA

UNEM
Computational Thinking I

Unit 3
Technological tools for algorithm design

Topic 2
Program Coding and Compilation
UNEM
I
Aim
Develop practical skills that allow structuring logical thinking and enhancing students'
digital creativity by allowing them to design their own graphic programs.

Introduction
❑ Program coding and compilation is the key process in software development, where ideas are transformed into
executable code.
❑ By writing instructions in a programming language, ideas are translated into algorithms and digital solutions are
created.
❑ Compilation converts the source code into an executable program, optimizing its performance and guaranteeing
its correct functionality.
❑ Mastering these concepts is essential to materialize your ideas and build powerful computer applications.
UNEM
I

Subtopics

» Subtopics:
1 .- Image library.
2 .- Conditional structures: “Yes, then”
3 .- Loops and animations.
4 .- Tickets and events.
UNEM
SUBTEMA 1.- Image library
I

A library or image bank is a repository that


stores figures, in different formats and sizes,
to be used as visual resources or support
material.

Scratch has a library of images for scenery


backgrounds, objects, and characters. The
From Juan Sánchez de Rojas, M. Q. (2021). Scratching. Ministry of Education and same one that allows you to search by
Vocational Training of the Government of Spain. [Figure 1]. Recovered from:
https://leer.es/wp- category.
content/uploads/2021/06/guia_didactica_actualizacion_scratch3_0.pdf
Insert an image UNEM
I
Click on the object icon to display the
options:
• Choose an object from the image library.
• Create a figure in the image editor.
• Choose a random image.
• Import downloaded images from
external repositories, captured using
cameras or other devices, or created in
graphic design editors.
From Juan Sánchez de Rojas, M. Q. (2021). Scratching. [Figure 2]. Recovered from:

https://leer.es/wp-content/uploads/2021/06/g
uia_didactica_actualizacion_scratch3_0.pdf UNEM
I
In the library a menu is presented with the UNEM
classifications of different types of images
D Scratch 3.29.1 I
UNEM
How to add a background? I
UNEM
Click on scenario to display the
different options, such as: Choose
I
a background, create a
background, choose a random
background, or upload an external
image
UNEM
In the library there is a menu with the classifications of different types of funds.
Scratch 3.29.1 I

UNEM
Costumes I
Space that allows images to be added, which are associated with the
object. There are different options and tools to do it.
UNEM
In the paint option there is a space to create or edit an object I
Image management options UNEM
I
Scenery

B Upload
costume
Allows you to upload an image previously stored in jgp or png format

Insert an image randomly


B
Surprise

H Open a space to create an object


D
Paint

Choose a
Allows you to select an image from the Scratch library
costume
UNEM
SUBTEMA 2.- Conditional structures: “Yes, then”
I
They are instructions that allow a
Simple Conditional Algorithm
condition to be evaluated and
age
determine what task to execute if its
«t age>=18 b--
result is true.
You can specify the action to take when
Younger' Adult
the condition is false, however this is
not always required. If not specified, the
EndAlgorithm
program will skip said scenario.
Botello, D. (2017). Conditional structures – Programming.
[Figure 3]. Recovered from: http://yoaprendo-
informatica.blogspot.com/2017/04/estructura-de-conditionales.html
There are two types of conditional blocks in Scratch:

1) Specifies the condition ( if) and the action to take only in the true (then)
UNEM
scenario.
I
UNEM
2) The second block also allows determining the task to be performed if the
condition is false (else).
I
UNEM
Conditional structures: “If, then”
I
Nested expressions:
It is possible to configure conditional blocks one inside
another, to evaluate several conditions and specify
actions according to different scenarios.
It is important to remember that the execution is
sequential. For example, in the code shown if both keys
(A and B) are pressed at the same time, only the action
of key A will be executed, since the code will never enter
the scenario where this condition is false, and therefore
will not will evaluate to the B key. Pallo, D., Delgado, R. (2020). Module 4: Basic programming
with Scratch. [Figure 6]. Retrieved from:
https://roa.cedia.edu.ec/webapps/55
UNEM
Exercise 1: Conditional
I
Run a program that asks the age and
determines if it is an adult or a minor

Clicking

ask (Xe7EE33E6G1312E9) and wait I


if answer > ol then E say (2213723212) for € seconds

but

say (=212) for () seconds


stop this program -
UNEM
I
UNEM
SUBTEMA 3.- Loops and animations
I
Animations
Cartoon characters appear to move, but in
reality what you are simply visualizing are many
slightly different images that trick your brain into
seeing the movement that is generated.
This is called animation.
Objects in Scratch can be animated in the same
way.
UNEM
Exercise 2: Cat walks
I
For this exercise, an object and a costume
will be created to perform the animation.
UNEM
To animate the cat, drag these blocks, as seen in
the image, and run the program. I
UNEM
The loop repeats and the image of the object
changes every half second, making it appear that I
the cat is walking.

Challenge: Try adding a block


Movement in the loop to improve the animation
"OR. 5 1

. next costume
UNEM
Exercise 3: Ballerina Dances
I
This exercise is posed as a challenge, practice the
animation of the following object, in the image
library you will find the dancer, she has four
costumes. Ballerina-a Ballerina-b
Click on the Costumes tab to view them. When
the show runs, she uses all of them to dance on
stage.

Ballerina- Ballerina-
c d
UNEM
Exercise 4: Object Party
I

Try adding a bunch of dancing objects to


your project.
Choose objects that have two or more
suits.
UNEM
SUBTEMA 4.- Tickets and events I

• Data entered into a program, such as the answer


you type when Scratch asks a question, are called
inputs .
• Events are actions, such as clicking an object or
pressing a chosen key, that Scratch can use to
execute scripts.
Events
UNEM
I
Motion

Clicking

Ap
pe

an
ce
ar
Sound when pressing space
key

Events
when clicking on this object

Control

Events
when the background backg
changes to round
1
Sensors

Operators when sound volume

Variables

my blocks
UNEM
Exercise 5: Question with Scratch I
Objects can use questions and answers using the light blue question and answer
blocks on the Sensors tab.

Drag these blocks, as seen in the


image and run the program. What Clicking

do you think it does? run it . ask What carreer do you I and wait
study?

think join I study: response during seconds


UNEM
IUNEMI
yEuukomua= iLove " m
mmpimj p-
stop all *

1 EmMu
In the blue response block, the
Initial education information entered by keyboard is
stored

In the Operators section


we find the green block
that unites the word “I
—p—--
•W
study” with the answer What carreer do you study?) 2m
that has been written.
Yaesiicic: )
UNEM
I
UNEM
I
• When the ENTER key is pressed, what is typed becomes the value of the response
(data entry) block.
• The response block works just like a variable. Wherever you put the Answer block
it will be replaced by whatever we answer to the question.
• The green Join block in the program above just takes what's in its two windows
and joins them as a single element.

bin apple banan


d a
UNEM
Activate events I
Events

• Events are things that happen in programs to decide when pressing space key *
certain actions.
• For example, press keyboard keys and mouse when clicking on this object

buttons.
when background changes to
• The Event-type "header" blocks in the brown section background1 •

begin executing a program when a chosen event


happens, in the same way as the green flag button.
UNEM
Exercise 6: Activate keyboard events I

• Create programs like the one in


the image. when pressing
button
• Select a different key for each play Low Tom v sound until finished
version of the program.
Depending on the
• Event blocks are executed when pressed key sounds
the correct key is pressed. differently
when pressing button 2

play High Tom sound • until finished
UNEM
Bibliography I
• From Juan Sánchez de Rojas, M. Q. (2021). Scratching. Ministry of Education and Vocational Training of
the Government of Spain. Recovered of: https://leer.es/wp-
content/uploads/2021/06/guia_didactica_actualizacion_scratch3_0.pdf
• Pallo, D., Delgado, R. (2020). Module 4: Basic programming with Scratch. ESPE Armed Forces
University. Retrieved from: https://roa.cedia.edu.ec/webapps/55
• Botello, D. (2017). Conditional structures – Programming. Retrieved from: http://yoaprendo-
informatica.blogspot.com/2017/04/estructura-de-conditionales.html
• López García, J. c. (2013). Reference Guide – SCRATCH. Eduteka. Recovered from:
https://eduteka.icesi.edu.co/pdfdir/ScratchGuiaRereference.pdf
• Rodríguez, F. (2012). Conditional structures in programming. Retrieved from:
https://programacionluzedu.wordpress.com/2012/06/27/estructuras-conditionales-en-java/
• González, D. (2019). Scratch 3.0 for young programmers. Madrid, Spain: Anaya Multimedia.
• MIT. (sf). Scratch - Imagine, Program, Share. Retrieved March 10, 2020, from
UNEM
https://scratch.mit.edu/ I

You might also like