Term2 Comp Scratchalgo
Term2 Comp Scratchalgo
1
1.Algorithm & Flowchart to find the smallest of two numbers: 2. Algorithm & Flowchart to find the largest of two numbers:
3. Write an algorithm to determine a student’s final grade and Write an algorithm that accept an integer number from the
indicate whether it is passing or failing. The final grade is user, in case of the number is Positive, check and print out
calculated as the average of four marks. whether it is Even or Odd number.
2
Write An Algorithm That Read Student's Mark As Integer Then Print the Equivalent Grade Depends On The Following Table:
3
Conditionals in scratch:
Conditional statements have conditions and the programs flow based on the true
or false value of the condition. They are found in the control programming blocks
as shown in the picture.
Here, if() then and if() then else are the conditional blocks.
2. if-then-else
It is a control block. This block is an extension of the if-then value.
If a condition is true, then a set of lines gets executed.
If a condition is false, then else part is executed.
Operators in scratch:The Operators blocks are used to compare 5) There are blocks for working with text strings:
variables and values, do calculations with numbers, and work with
4
strings (text). a) join block
You can choose random numbers between the smallest and largest This operator block reports the number of characters that a
number (including those numbers) using below operator. given string (input) contains.
Letter () block:
4) And, or, not Operators:
The and, or, and not operators can be used to combine conditions.
This block reports the specified character of the given text.
Even though the block says "letter", it will report all
characters, including letters, numbers, symbols, and even
spaces.
Variables in Scratch:
Here,
5
In Scratch programming language variables are similar to variables Variable: This block is used to reports the value of a
in other programming languages. variable
set variable to 0: This block sets a selected variable
A variable is a named value or data storage location that can hold a
to a specified value.
value or information that can be changed during the execution of a
program. change variable by 1: This block changes the value
of the selected variable.
Variables are used to store data that a program can access and show variable: This block displays the specified
manipulate as needed. variable in the project player.
hide variable: The block reverses the “show
Scratch contains the following variables blocks:
variable” block.