loops/questions.rst
changeset 468 ac1198488c0e
parent 462 3a1575a45152
equal deleted inserted replaced
467:501383b753c1 468:ac1198488c0e
    13    #. list of strings
    13    #. list of strings
    14    #. strings
    14    #. strings
    15    #. tuples
    15    #. tuples
    16    #. all of the above
    16    #. all of the above
    17 
    17 
       
    18    Answer: all of the above
       
    19 
    18 .. I was not sure of how to frame this question. Can someone fix it?
    20 .. I was not sure of how to frame this question. Can someone fix it?
    19 
    21 .. #[bhanu: it works for every `sequence` or an iterator for that matter right?]
    20    Answer: all of the above
       
    21 
    22 
    22 #. ``x = range(20)``. What is x?
    23 #. ``x = range(20)``. What is x?
    23 
    24 
    24    Answer: A list of numbers from 0 to 19. 
    25    Answer: A list of numbers from 0 to 19. 
    25 
    26 
    83              continue
    84              continue
    84              print i * j
    85              print i * j
    85 
    86 
    86    Answer: Nothing is printed
    87    Answer: Nothing is printed
    87 
    88 
    88 .. #[[Anoop: I think more questions on while loop has to be added as
    89 .. #[[Anoop: I think more questions on while loop have to be added as
    89    for loop was already covered in another LO, these questions can be
    90    for loop was already covered in another LO, these questions can be
    90    kept, but it will good if we add few more on while loop]]
    91    kept, but it will good if we add few more on while loop]]
    91 
    92 
    92 Larger Questions
    93 Larger Questions
    93 ----------------
    94 ----------------
    94 
    95 
    95 1. A number is called Armstrong number if the sum of cubes of its digits is
    96 1. A number is called Armstrong number if the sum of cubes of its digits is
    96    equal to the number itself. Find all the three digit Armstrong numbers.
    97    equal to the number itself. Find all the three digit Armstrong numbers.
    97 
    98 
    98 .. #[[Anoop: Add one more question]]
    99 2. Collatz sequence - Given a number ``n``, multiply by 3 and add 1 to
       
   100    it, if it is odd, otherwise divide it by two. With whatever ``n``
       
   101    we start with, we finally end with the sequence 4, 2, 1. Write a
       
   102    program to print this, given some number ``n``.