basic-data-type/questions.rst
changeset 337 c65d0d9fc0c8
parent 320 223044cf254f
child 406 a534e9e79599
equal deleted inserted replaced
326:c4cb18752ade 337:c65d0d9fc0c8
     1 Objective Questions
     1 Objective Questions
     2 -------------------
     2 -------------------
     3 
     3 
     4 .. A mininum of 8 questions here (along with answers)
     4 .. A mininum of 8 questions here (along with answers)
       
     5 
       
     6 .. #[Puneeth: ``Answer: Any size.``. Demarcate the answer from the
       
     7 .. question.]
     5 
     8 
     6 1. How large can an integer in Python be?
     9 1. How large can an integer in Python be?
     7 
    10 
     8    Any Size.
    11    Any Size.
     9    
    12    
    16    example ::
    19    example ::
    17    
    20    
    18    c= 3.2 + 4.6j
    21    c= 3.2 + 4.6j
    19 
    22 
    20 
    23 
    21 
       
    22 3. Look at the following piece of code ::
    24 3. Look at the following piece of code ::
    23    
    25    
    24    In []: f or t 
    26      In []: f or t 
    25    Out[]:True
    27      Out[]:True
    26 
    28 
    27    What can you comment about the data type of f and t ? 
    29    What can you comment about the data type of f and t ? 
    28 
    30 
    29 4. One major diffence between tuples and lists?
    31 4. One major diffence between tuples and lists?
    30 
    32 
    31    Tuples are immutable while lists are not.
    33    Tuples are immutable while lists are not.
    32 
    34 
    33 
    35 
    34 5. Look at the following sequence ::
    36 5. Look at the following sequence ::
    35 
    37 
    36    In []:t=true
    38      In []:t=true
    37    NameError: name 'true' is not defined
    39      NameError: name 'true' is not defined
    38 
    40 
    39    What might be the reason for error here?
    41    What might be the reason for error here?
    40 
    42 
    41    In this scenario , it seems the programmer wanted to create a variable t with the boolean value True with a capital T. Since no variable by the name true(small t) is known to the interpreter it gives a NameError. 
    43    In this scenario , it seems the programmer wanted to create a
       
    44    variable t with the boolean value True with a capital T. Since no
       
    45    variable by the name true(small t) is known to the interpreter it
       
    46    gives a NameError.
    42 
    47 
    43 
    48 
    44 6. Put the following string in a variable quotation.
    49 6. Put the following string in a variable quotation.
    45    "God doesn't play dice" -Albert Einstein
    50    "God doesn't play dice" -Albert Einstein
    46 
    51 
    47    quotation='''"God doesn't play dice" -Albert Einstein'''
    52    quotation='''"God doesn't play dice" -Albert Einstein'''
    48 
    53 
    49 7. Given a tuple ::
    54 7. Given a tuple ::
    50 
    55 
    51    tup=(7,4,2,1,3,6,5,8)
    56      tup=(7,4,2,1,3,6,5,8)
    52    tup[-2]
    57      tup[-2]
    53   
    58   
    54    5
    59    5
       
    60 
       
    61 .. #[Puneeth: ``Answer: Any size.``. Demarcate the answer from the
       
    62 .. question.]
    55 
    63 
    56 8. What is the syntax for checking containership in Python?::
    64 8. What is the syntax for checking containership in Python?::
    57 
    65 
    58    element in sequence 
    66    element in sequence 
    59    'l' in "Hello"
    67    'l' in "Hello"
    76 .. A minimum of 2 questions here (along with answers)
    84 .. A minimum of 2 questions here (along with answers)
    77 
    85 
    78 1. Given two lists for example,
    86 1. Given two lists for example,
    79    list1=[1,2,3,4] and list2=[1,2,3,4,5,6,7] write a program to remove one list from the other.
    87    list1=[1,2,3,4] and list2=[1,2,3,4,5,6,7] write a program to remove one list from the other.
    80 
    88 
       
    89 .. #[Puneeth: dependency LOs?]
    81 
    90 
    82 #. Write a program to check if a string is palindrome?
    91 #. Write a program to check if a string is palindrome?
    83 
    92 
       
    93 .. #[Puneeth: comparison has not been taught, has it? does this depend
       
    94 .. on any other LO?]