Page 283 - Computer Science V2.0 Class 11
P. 283

Sample Output:
                  >>> Enter first number  :3
                  >>> Enter second number :2
                  >>> Enter third number  :1
                      Maximum of 3 2 1 :  3


                         1.  Which conditional statement can check for multiple values of a single variable?
                         2.  Name any two operators that are used to join two or more Boolean conditions.




                      Let's Summarise


                   Ø   The order of execution of the statements in a program is known as flow of control.

                   Ø   In sequential flow, the program begins with the execution of the first statement and continues with the rest
                      of the statements in a sequential manner.

                   Ø   In the case of conditional  flow, the execution of the statements depends upon  whether the conditional
                      expression yields True or False.
                   Ø   A compound statement often spans several lines. It comprises one or more header clauses and one or more
                      sequences of statements, called suites.
                         A header clause begins with a keyword and ends with a colon.
                         A suite may comprise one or more statements.
                         The suite, following a header clause, appears at the next level of indentation.

                   Ø   pass statement is ignored by the interpreter.
                   Ø   An if statement executes a sequence of statement(s) if the conditional expression yields (on evaluation)
                      True.
                   Ø   if-else statement is used when:
                         a sequence of statements is to be executed if the conditional expression yields (on evaluation) True.
                         another sequence of statements is to be executed if the conditional expression yields (on evaluation)

                         False.
                   Ø   An  elif  clause  is  used  when  different  actions  are  required  to  be  taken  based  on  different  conditions
                      (often different values of a single control variable).

                   Ø   An  if/if-else/if-elif-else statement is called  nested if it encloses another  if/if-else/
                      if-elif-else statement.






                                                       Solved Exercises


                 A.  Multiple Choice Questions.
                    1.  Which of the following if statement is syntactically correct?
                      a.  if number >=10:
                      b.  If (number >= 10)
                      c.  if number >= 10, then
                      d.  If number >=10 then

                                                                                               Conditional Statements  269
   278   279   280   281   282   283   284   285   286   287   288