Page 510 - ComputerScience_Class_11
P. 510

MIND DRILL


                   Solved Questions


              A.  Tick ( ) the correct option.
                    1.  Which statement is used to repeat actions in Python?
                    a.  if                                          b.  else
                    c.  for / while                                 d.  print
                  2.  Which loop is used when the number of iterations is known beforehand?
                    a.  for loop                                    b.  do-while loop
                    c.  while loop                                  d.  infinite loop
                  3.  According to PEP 8 guidelines, how many spaces should be used for indentation?
                    a.  2 spaces                                    b.  3 spaces
                    c.  8 spaces                                    d.  4 spaces
                  4.  Which symbol is used instead of curly braces in Python to define blocks?
                    a.  Semicolon                                   b.  Indentation
                    c.  Colon only                                  d.  Comma
                  5.  What happens when an if condition is False?
                    a.  Program stops                               b.  Error occurs
                    c.  Block is skipped                            d.  Loop starts
                 Answers
                 1.  c           2.   a          3.  d          4.  b           5.  c

              B.  Fill in the blanks.
                  1.  ………………… refers to the sequence in which statements or function calls are executed within a program.
                  2.  Indentation refers to the ………………… or tabs used at the beginning of a line of code to define the structure of the program.
                  3.  Sequential flow of control refers to the ………………… order in which instructions in a program are executed.
                  4.  The ………………… statement is one of the most fundamental control structures in Python, allowing the program to make decisions
                    based on a condition.
                  5.  A ………………… statement is used when you want to check a condition inside another condition.
                Answers
                  1.  Flow of control    2.  Spaces    3.  Default     4.  If     5.  Nested if

              C.  Answer the following questions:
                  1.  What is a control variable in a loop?
                Ans.  A control variable is a variable whose value changes during loop execution and controls the loop’s repetition.
                  2.  Define the term programming construct.
                Ans.  A programming construct is a structure used to control the flow of execution in a program, such as conditional and iterative
                    statements.
                  3.  What is a nested if statement?
                Ans.  A nested if statement is an if statement placed inside another if, elif or else block to check multiple conditions hierarchically.
                  4.  What is the purpose of loop control statements?
                Ans.  They modify loop execution by stopping, skipping or doing nothing in an iteration using break, continue and pass.
                  5.  What are entry-controlled loops? Does Python support exit-controlled loops?
                Ans.  Entry-controlled loops check the condition before entering the loop body. If the condition is False initially, the loop does not
                    execute.  Both  for  and  while  loops  in  Python  are  entry-controlled  loops.  Python  does  not  support  exit-controlled  loops  like
                    do-while or repeat-until.



                  508  Touchpad Computer Science (Ver. 3.0)-XI
   505   506   507   508   509   510   511   512   513   514   515