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 #. Given a file with 3 columns of data but two different delimiters, |
|
60 what do you think will happen? |
|
61 |
|
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``] |
|
67 |