Page 52 - Code & Click - 7
P. 52

P
             Post-Processingost-Processing
                Decision-making is the process of evaluating a given condition and deciding the course of
                  action to follow based on the result of the condition.
                The statements that let us take decisions based on conditions in a Python program are

                  called Conditional statements.
                Conditional statements in Python include the If statement, the If … Else statement, the
                  Nested If … Else statement, and the If … Elif … Else ladder.



                                                        Info Retention
            A.   Select the correct option for each of the following statements.
                1.   In Python, the simplest conditional statement is ______.
                    (a)  Choose             (b)  If                   (c)  Select             (d)  Test
                2.  An if statement within another if statement is called ______.
                    (a)  Blocked if         (b)  Stored if            (c)  Nested if          (d)  Caged if
                3.  What is the output of the following code segment?
                        X = 45
                        Y = 60
                        if (X > Y):
                           print(X + Y)
                        else:
                           print(Y – X)
                    (a)  60                 (b)  15                   (c)  45                 (d)  105
                4.  The symbol used to denote the beginning of a block of statements in Python is ______.
                    (a)  #                  (b)  { }                  (c)  ;                  (d)  :

            B.  Fill in the blanks with the correct answer.
                1.  The _________ statements are used to take decisions based on a test condition.

                2.  The Nested if … else statement encloses an if statement within another _________ statement.
                3.  The if … elif … else statement is also called a _________.

                4.  The _________ function lets you accept data from the user and store it in a variable.
            C.  Write ‘T’ for True and ‘F’ for False statement.
                1.  The input( ) function treats all data as string.                                       _______

                2.  Every if statement must have a corresponding else statement.                           _______
                3.  Indentation of statements in the code makes it look colourful.                         _______
                4.  Conditional statements divide the flow of control of a program in different directions. _______

            D.  Answer the following questions.
                1.  What is decision making?
                2.  What are Conditional statements?

                3.  What is Indentation of statements in Python? What is its benefit?
                4.  Explain the working of the if … else statement with an example.


            50
   47   48   49   50   51   52   53   54   55   56   57