Sample test 1 with solutions

(This test is modified from some previous years' tests)

CSC 104 Test #1
Time allotted: 45 minutes

No aids permitted.

Since time is short, be careful not to get stuck on one question to the exclusion of others. The amount of marks or answer-space allotted does not indicate how long it will take you to complete the question, nor does the size of the answer-space indicate the size of the correct answer.

Answer all questions. Answer questions in the space provided.

Do not open this booklet until you are instructed to.


1.

Polya's problem-solving phases include the phases "3. Carry out the plan" (the plan for solving the problem, that you formulated in phase #2) and "4. Evaluate the solution for accuracy".

Give an example of a problem-solving task in which these phases overlap, stating what part of "carry out the plan" would typically be performed during or after what part of "evaluate the solution".

Possible solution:

There are many possible solutions here, but basically the most likely format of solution would involve a multi-step plan where early portions are evaluated for accuracy before performing later portions.

For example, I (ajr) am going to print test papers which have students' names pre-printed on the covers. This involves writing a little program. While the tests are printing, I'm going to be standing by the printer (for security!) and I will be examining the tests as they print, to make sure that everything is coming out right. I will be evaluating the correctness of my little program while more batches are still printing and more batches are yet to be printed. This is useful because if there is something wrong, I would like to catch it early and not actually go through with the rest of the printing until I fix my little program.


2.

a) Give one example of a kind of "primary storage" (main memory).
Solution: Most likely answer is: RAM
Other sorts of descriptions of main memory will be accepted, but not just the word "memory".
(This part is worth only 1 of the 3 points for this question.)

b) Give one example of a kind of "secondary storage".

Some solutions (pick any one): disks, floppy disks, tape, punch cards, USB flash drive. (not an exhaustive list)


3.

Write the mathematical formula
as a numeric expression in a text format suitable for use in a typical programming language (such as Python). (The raised "a+b" indicates exponentiation. You can use "**" as the exponentiation operator.)

Solution:

((x + y) / z) ** (a + b) + 12

Extra parentheses are fine. However, square brackets ("[" and "]") mean something different, in python and in almost all programming languages (although what they mean differs between programming languages -- in Python it indicates list literals); students who used any square brackets did not get full marks for this question.


4.

Consider the following filesystem hierarchy:

Write absolute path names to specify the following three files:

a) the "cat" program (on the left)

Solution:   /bin/cat

b) the "z" file (lowest on the diagram)

Solution:   /u/csc104h/summer/pub/x/z

c) my (ajr's) "hello" file

Solution:   /u/ajr/hello

If your current directory is my home directory (the ajr directory), write relative path names to specify the following three files:

d) my "hello" file

Solution:   hello

e) my "checkq5" file

Solution:   104/checkq5

f) the "u" directory near the top

Solution:   ..


5.

How would you use the Python interpreter to find out what 1234 times 2345 is? Specify everything that you would type after logging in to your CDF account.

Sample solution:

Select the "Terminal" application icon. Type "python" at the command prompt in the terminal window. To the python interpreter, type "print 1234 * 2345" (return).


[main course page]