diff -r 88a01948450d -r d33698326409 loading_data_from_files/questions.rst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loading_data_from_files/questions.rst Wed Dec 01 16:51:35 2010 +0530 @@ -0,0 +1,67 @@ +Objective Questions +------------------- + +.. A mininum of 8 questions here. + +1. ``loadtxt`` can read data only from a file with one column + only. True or False? + + Answer: False + +#. To read a file with multiple columns, into separate simple + sequences, ``loadtxt`` is given the additional argument ______? + + Answer: ``unpack=True`` + +#. We have a file with two columns of data separated by one of the + following characters. Which of them doesn't require the delimiter + argument to be specified, when using ``loadtxt``. + + a. ; + #. , + #. : + #. [space] + + Answer: [space] + +#. Given a file ``data.txt`` with three columns of data separated by + spaces, read it into one complex sequence. + + Answer: ``x = loadtxt("data.txt")`` + +#. Given a file ``data.txt`` with three columns of data separated by + spaces, read it into 3 separate simple sequences. + + Answer: ``x = loadtxt("data.txt", unpack=True)`` + +#. Given a file ``data.txt`` with three columns of data separated by + ``:``, read it into one complex sequence. + + Answer: ``x = loadtxt("data.txt", delimiter=":")`` + +#. Given a file ``data.txt`` with three columns of data separated by + ":", read it into 3 separate simple sequences. + + Answer: ``x = loadtxt("data.txt", unpack=True, delimiter=":")`` + +#. To use the loadtxt command, each row should have the same number of + values, T or F ? + + Answer: True + +Larger Questions +---------------- + +.. A minimum of 2 questions here. + +1. What will happen if one of the cells is empty? + +#. Given a file with 3 columns of data but two different delimiters, + what do you think will happen? + +#. Read a column with text? + +#. An input file contains 5 columns of data. Use only the second and fourth + columns of data and load into two different variables. + [hint: read the documentation, use the argument ``usecols``] +.. #[bhanu: solutions are not seen to have been included.]