Page 60 - Digicode_AI_class_7
P. 60

Critical Thinking
                   code Quest



                 Look at these binary codes of numbers 1–10.

                             Number           Binary                   Number           Binary
                                 1             0001                        6             0110

                                 2             0010                        7             0111

                                 3             0011                        8             1000
                                 4             0100                        9             1001

                                 5             0101                       10             1010


                 Now answer the following in binary digits:
                 1.  Write all the prime numbers between 1 and 10.


                 2.  Write all the even numbers between 1 and 10.



                 3.  Write the sum of 5 and 4.


                 4.  Write all the numbers divisible by 3 between 1 and 10.






            Conditions in a Program

            While writing a program, we need to make certain decisions based on the logic of the program.
            Such situations are called conditions. Conditional statements are used in a program to instruct the
            computer to make a decision. The result of the computer’s decision for a condition will always be
            either a true or a false.
            if-then-else

            The program executes the statements written after ‘if’ when the condition is true. If it is false, the
            statements written after ‘else’ will be executed.





                                          Yes           If (Condition)          No
                                                        to be checked
                                         Then                                   Else
                             Do this                                                    Do that




                 58    DigiCode AI-VII
   55   56   57   58   59   60   61   62   63   64   65