Page 219 - Ai_V1.0_Class9
P. 219

Maths are as follows:
                 Step 1   Start
                 Step 2   Input Eng, Science, Math
                 Step 3   Total = Eng+Science+Math

                 Step 4   Percentage = (Total / Maximum_Marks) * 100
                 Step 5   Display Percentage
                 Step 6   Stop


                 Selection Flow
                 Selection flow is also known as branching control as the flow of control branches based on a condition. A
                 condition evaluates to either TRUE or FALSE. In the case of TRUE, the flow of control follows the set of instructions
                 written for True. In case it is FALSE, then it follows the other route. For example, consider the scenario where an
                 award is given only if the percentage is more than 90:
                 Step 1   Start

                 Step 2   Input Eng,Science, Math
                 Step 3   Total= Eng+Science+Math
                 Step 4   Percentage = (Total / Maximum_Marks) * 100

                 Step 5   Display Percentage
                 Step 6   If Percentage> 90 then
                              Display "Award given"
                 Step 7   else
                              Display "No award"
                 Step 8   Stop


                 Repetition Flow
                 Repetition flow, also known as a loop, repeats a set of instructions a number of times based on a condition. For
                 example, if we wish to repeat the above steps of calculating percentage for 10 students then we use the concept
                 of repetition.
                 Step 1   Start

                 Step 2   count=1
                 Step 3   if count <=10 goto Step 4 else goto step 10
                 Step 4   Input Eng,Science, Math
                 Step 5   Total= Eng+Science+Math

                 Step 6   Percentage = (Total / Maximum_Marks) * 100
                 Step 7   Display Percentage
                 Step 8   count=count+1
                 Step 9   Goto Step 3

                 Step 10  Stop

                         Algorithm


                 An algorithm is a step-by-step approach to identify and solve a problem in a finite amount of time. It is used
                 in  the  problem-solving  phase  of  any  programming  task  and  helps  in  defining  clear  instructions  in  sequence.

                                                                                        Introduction to Python  217
   214   215   216   217   218   219   220   221   222   223   224