Page 45 - CT_AI_Class-5
P. 45

Step 6   Your hot chocolate is ready. Enjoy!

                 Step 7   End

                 Selection

                 In selection, the algorithm comes to a point where it needs to ask a question. The

                 answer (YES or NO), decides which path it will follow next. Different answers lead to
                 different steps, helping the algorithm make smart choices.

                 For example, deciding what to wear today.

                 Algorithm:

                 Step 1   Start

                 Step 2   Wake up and look outside the window.

                 Step 3   Check if it is cold today.

                           If YES, wear a warm sweater and trousers.

                          If NO, wear a light t-shirt and shorts.
                 Step 4   Put on your chosen clothes.


                 Step 5   Check yourself in the mirror.
                           If YES, you are happy with your look →

                           Move to Step 6.

                           If NO, you are not happy → Go back to
                           Step 3 and choose again.

                 Step 6   You are dressed and ready for the day.

                 Step 7   End

                 Repetition

                 In repetition, some steps are repeated again and again. The algorithm keeps doing

                 the same step until a certain condition becomes true and then moves forward. This
                 helps us avoid writing the same steps many times.

                 For example, practising multiplication tables.

                 Algorithm:

                 Step 1   Start

                 Step 2   Choose a number (for example, 5).

                 Step 3   Set a counter to 1.





                                                                                          Algorithmic Thinking     43
   40   41   42   43   44   45   46   47   48   49   50