loops/questions.rst
changeset 254 c43677920502
parent 217 b595f90016c5
child 293 ca701f1ef7fb
equal deleted inserted replaced
253:8a117c6e75f1 254:c43677920502
     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
       
    17 
       
    18 .. I was not sure of how to frame this question. Can someone fix it?
       
    19 
       
    20    Answer: all of the above
       
    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      1
       
    75      2
       
    76      3
       
    77      2
       
    78      4
       
    79      6
       
    80      3
       
    81      6
       
    82      9
       
    83 
       
    84 #. What is the output of the following code block?
       
    85    ::
       
    86 
       
    87      for i in range(1, 4):
       
    88          for j in range(1, 4):
       
    89              continue
       
    90              print i * j
       
    91 
       
    92    Answer: Nothing is printed
       
    93 
       
    94 Larger Questions
       
    95 ----------------
    13 
    96 
    14 .. A minimum of 2 questions here. 
    97 .. A minimum of 2 questions here. 
    15 
    98 
    16 1. Programming Assignment 1
       
    17 2. Programming Assignment 2