Algorith Thinking
Algorith Thinking
Repetitive tasks are common in programming. The concept of iteration allows one to repeat a
certain section or instructions of code required number of times by writing only a few commands
without having to manually repeat the instructions. For example, if a message needs to be printed
200 times, it would be efficient to do so with the help of an iterative statement rather than typing it
Manually.
d. Give examples of everyday situations where ‘if else’ conditional statement can be used?
ii. Making tea – put tea leaves if the milk boils else wait.
iii. Going out in rainy season – take umbrella if it’s raining else not
ii. Access or gather the data both current and past data.
iv. Use logical reasoning to draw a proper relationship between input and output.
Conditional statements refer to the statements that allow the algorithm to take one or more
path. It works by evaluating a condition and proceeds further if the condition is met else the
algorithm takes an alternative route or set of instructions.
The finite loops repeat the specified steps or set of instructions a set or finite number of times.
While an infinite loop runs forever unless stopped by an external factor.
The sequence statements represent the order of the steps in an algorithm. An example of
sequence
START
ADD firstnumber+secondnumber=result
SHOW result
END
Extra.
A conditional statement is like a rule that tells you what to do based on a certain situation. It's
like saying, "If this happens, then do that." It helps you make decisions depending on what is
going on around you.
Define pseudocode?
Pseudocode is a way of planning and describing a computer program using simple and easy-to-
understand instructions, kind of like writing out the steps in a story. It's not a real programming
language, but it helps programmers organize their thoughts before they start writing actual
code.
Unit:04 Algorithm Thinking
Define loops?
Sequence:
Selection:
Repetition:
1. Write the steps to play the ‘snakes and ladder’ game. Review the steps and use iteration, where
required?
The steps to play snake and ladder game are given below:
i. Put your counter at the initial point in the board to begin the game.
ii. Move your counter according to the number of spaces shown in the dice
iii. If the counter lands at the bottom of the ladder, move up the ladder
iv. If your counter lands on the head of the snake slide to the bottom of snake
v. If either of this doesn’t happen, proceed with the count in normal order
vi. The first player to reach the end or home; is the winner.
BEGIN
REPEAT
MOVE counter
IF counter=bottom Ladder
climb up
IF counter=snakehead
climb down
ELSE
count+1
STOP
Unit:04 Algorithm Thinking
In The Lab
START
DEFINE h,m (this defines the placeholder for hour and seconds minutes)
m=h*60
DISPLAY m
END
START
DEFINE ml, l (indicate value placeholders for milliliters and liters respectively)
DISPLAY ml
END
START
IF toys=RED
PLACE in red-Basket
ELSE
PLACE in Blue-Basket
REPEAT step 3
Group project
1. Planning a trip: students can work in group to plan a trip, such as a comping trip or a day
trip, they can use computational thinking to design an algorithm that covers transportation
,accommodation, activities and budget?
b. Keeping budget in mind, making a list of places that can be travelled within the specified budget.
2. Creating a robot: students can work in groups to design and build a simple robot that can
perform a specific task, such as avoiding obstacles or following a line. They can use computational
thinking to design an algorithm that controls the robot’s movements?
START
MOVE FORWARD
MOVE BACKWARD
MOVE RIGHT
MOVE LEFT
END