loops/questions.rst
changeset 324 4054b1a6392d
parent 293 ca701f1ef7fb
child 366 894591150f7b
equal deleted inserted replaced
323:e675f9208b91 324:4054b1a6392d
     1 Objective
     1 Objective Questions
     2 ---------
     2 -------------------
     3 
     3 
     4 .. A mininum of 8 questions here. 
     4 .. A mininum of 8 questions here. 
     5 
     5 
     6 1. Question 1
     6 1. Braces are used to indicate blocks in Python. True or False?
     7 2. Question 2
       
     8 3. Question 3
       
     9 
     7 
       
     8    Answer: False
    10 
     9 
    11 Programming
    10 #. ``for`` can iterate over 
    12 -----------
    11    
       
    12    a. list of numbers
       
    13    #. list of strings
       
    14    #. strings
       
    15    #. tuples
       
    16    #. all of the above
    13 
    17 
    14 .. A minimum of 2 questions here. 
    18 .. I was not sure of how to frame this question. Can someone fix it?
    15 
    19 
    16 1. Programming Assignment 1
    20    Answer: all of the above
    17 2. Programming Assignment 2
    21 
       
    22 #. ``x = range(20)``. What is x?
       
    23 
       
    24    Answer: A list of numbers from 0 to 19. 
       
    25 
       
    26 #. ``x = range(5, 20)``. What is x?
       
    27 
       
    28    Answer: A list of numbers from 5 to 19. 
       
    29 
       
    30 #. ``x = range(0, 20, 5)``. What is x?
       
    31 
       
    32    a. [5, 10, 15, 20]
       
    33    #. [0, 5, 10, 15, 20]
       
    34    #. [0, 5, 10, 15]
       
    35    #. Empty list
       
    36    #. None of the Above
       
    37 
       
    38    Answer: [0, 5, 10, 15]
       
    39 
       
    40 #. ``x = range(20, 5)``. What is x?
       
    41 
       
    42    a. [5, 10, 15, 20]
       
    43    #. [0, 5, 10, 15, 20]
       
    44    #. [0, 5, 10, 15]
       
    45    #. Empty list
       
    46    #. None of the Above
       
    47 
       
    48    Answer: Empty list
       
    49 
       
    50 #. ``x = range(20, 5, -1)``. What is x?
       
    51 
       
    52    Answer: A list of numbers from 20 to 6.
       
    53 
       
    54 #. What is the output of the following code block?
       
    55    ::
       
    56 
       
    57      for i in range(1, 4):
       
    58          for j in range(1, 4):
       
    59              print i * j
       
    60              break
       
    61 
       
    62    Answer: 1 to 3 is printed
       
    63 
       
    64 #. What is the output of the following code block?
       
    65    ::
       
    66 
       
    67      for i in range(1, 4):
       
    68          for j in range(1, 4):
       
    69              pass
       
    70              print i * j
       
    71 
       
    72    Answer::
       
    73      
       
    74      3
       
    75      6
       
    76      9
       
    77 
       
    78 #. What is the output of the following code block?
       
    79    ::
       
    80 
       
    81      for i in range(1, 4):
       
    82          for j in range(1, 4):
       
    83              continue
       
    84              print i * j
       
    85 
       
    86    Answer: Nothing is printed
       
    87 
       
    88 Larger Questions
       
    89 ----------------
       
    90 
       
    91 1. A number is called Armstrong number if the sum of cubes of its digits is
       
    92    equal to the number itself. Find all the three digit Armstrong numbers.
       
    93