loops/questions.rst
changeset 462 3a1575a45152
parent 453 b0e3f24bd78a
equal deleted inserted replaced
461:757418fff170 462:3a1575a45152
    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 ..#[bhanu: it works for every `sequence` or an iterator for that matter right?]
    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 
    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``.