author | anand |
Sun, 07 Nov 2010 01:18:26 +0530 | |
changeset 390 | 69f285b3a5ed |
parent 385 | bd9df13cd320 |
permissions | -rw-r--r-- |
250
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
1 |
Objective Questions |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
2 |
------------------- |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
3 |
|
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
4 |
.. A mininum of 8 questions here. |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
5 |
|
250
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
6 |
1. ``loadtxt`` can read data only from a file with one column |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
7 |
only. True or False? |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
8 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
9 |
Answer: False |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
10 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
11 |
#. To read a file with multiple columns, into separate simple |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
12 |
sequences, ``loadtxt`` is given the additional argument ______? |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
13 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
14 |
Answer: ``unpack=True`` |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
15 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
16 |
#. We have a file with two columns of data separated by one of the |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
17 |
following characters. Which of them doesn't require the delimiter |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
18 |
argument to be specified, when using ``loadtxt``. |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
19 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
20 |
a. ; |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
21 |
#. , |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
22 |
#. : |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
23 |
#. [space] |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
24 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
25 |
Answer: [space] |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
26 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
27 |
#. Given a file ``data.txt`` with three columns of data separated by |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
28 |
spaces, read it into one complex sequence. |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
29 |
|
250
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
30 |
Answer: ``x = loadtxt("data.txt")`` |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
31 |
|
250
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
32 |
#. Given a file ``data.txt`` with three columns of data separated by |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
33 |
spaces, read it into 3 separate simple sequences. |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
34 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
35 |
Answer: ``x = loadtxt("data.txt", unpack=True)`` |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
36 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
37 |
#. Given a file ``data.txt`` with three columns of data separated by |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
38 |
``:``, read it into one complex sequence. |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
39 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
40 |
Answer: ``x = loadtxt("data.txt", delimiter=":")`` |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
41 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
42 |
#. Given a file ``data.txt`` with three columns of data separated by |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
43 |
":", read it into 3 separate simple sequences. |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
44 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
45 |
Answer: ``x = loadtxt("data.txt", unpack=True, delimiter=":")`` |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
46 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
47 |
#. To use the loadtxt command, each row should have the same number of |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
48 |
values, T or F ? |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
49 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
50 |
Answer: True |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
51 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
52 |
Larger Questions |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
53 |
---------------- |
217
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
54 |
|
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
55 |
.. A minimum of 2 questions here. |
b595f90016c5
Changed structure of my scripts.
Puneeth Chaganti <punchagan@fossee.in>
parents:
diff
changeset
|
56 |
|
250
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
57 |
1. What will happen if one of the cells is empty? |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
58 |
|
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
59 |
#. Given a file with 3 columns of data but two different delimiters, |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
60 |
what do you think will happen? |
4d8ef03627b5
Added questions to loading data from files LO.
Puneeth Chaganti <punchagan@fossee.in>
parents:
217
diff
changeset
|
61 |
|
291 | 62 |
#. Read a column with text? |
63 |
||
64 |
#. An input file contains 5 columns of data. Use only the second and fourth |
|
65 |
columns of data and load into two different variables. |
|
66 |
[hint: read the documentation, use the argument ``usecols``] |
|
385
bd9df13cd320
check the questions and script for `loading data from files`
bhanu
parents:
291
diff
changeset
|
67 |
.. #[bhanu: solutions are not seen to have been included.] |