loading-data-from-files/questions.rst
changeset 250 4d8ef03627b5
parent 217 b595f90016c5
child 291 d83395820797
equal deleted inserted replaced
249:cad8e64dcd82 250:4d8ef03627b5
     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. ``loadtxt`` can read data only from a file with one column
     7 2. Question 2
     7    only. True or False?
     8 3. Question 3
       
     9 
     8 
       
     9    Answer: False
    10 
    10 
    11 Programming
    11 #. To read a file with multiple columns, into separate simple
    12 -----------
    12    sequences, ``loadtxt`` is given the additional argument ______?
       
    13 
       
    14    Answer: ``unpack=True``
       
    15 
       
    16 #. We have a file with two columns of data separated by one of the
       
    17    following characters. Which of them doesn't require the delimiter
       
    18    argument to be specified, when using ``loadtxt``. 
       
    19 
       
    20    a. ;
       
    21    #. , 
       
    22    #. :
       
    23    #. [space] 
       
    24    
       
    25    Answer: [space]
       
    26    
       
    27 #. Given a file ``data.txt`` with three columns of data separated by
       
    28    spaces, read it into one complex sequence. 
       
    29 
       
    30    Answer: ``x = loadtxt("data.txt")``
       
    31 
       
    32 #. Given a file ``data.txt`` with three columns of data separated by
       
    33    spaces, read it into 3 separate simple sequences. 
       
    34 
       
    35    Answer: ``x = loadtxt("data.txt", unpack=True)``
       
    36 
       
    37 #. Given a file ``data.txt`` with three columns of data separated by
       
    38    ``:``, read it into one complex sequence. 
       
    39 
       
    40    Answer: ``x = loadtxt("data.txt", delimiter=":")``
       
    41 
       
    42 #. Given a file ``data.txt`` with three columns of data separated by
       
    43    ":", read it into 3 separate simple sequences. 
       
    44 
       
    45    Answer: ``x = loadtxt("data.txt", unpack=True, delimiter=":")``
       
    46 
       
    47 #. To use the loadtxt command, each row should have the same number of
       
    48    values, T or F ?
       
    49 
       
    50    Answer: True
       
    51 
       
    52 Larger Questions
       
    53 ----------------
    13 
    54 
    14 .. A minimum of 2 questions here. 
    55 .. A minimum of 2 questions here. 
    15 
    56 
    16 1. Programming Assignment 1
    57 1. What will happen if one of the cells is empty?
    17 2. Programming Assignment 2
    58 
       
    59 #. Read a column with text? 
       
    60 
       
    61 #. Given a file with 3 columns of data but two different delimiters,
       
    62    what do you think will happen?
       
    63