Note: If you missed the test (e.g. with a medical note), I STRONGLY RECOMMEND that you not look at these solutions at first. I suggest you prepare to take the test, then print the PDF file of the test as actually given, then time yourself and write it in less than 45 minutes with no aids allowed (and don't answer the telephone, etc -- go to a library if necessary). Then look at these solutions, and bring me your completed test if you're unsure what your grade would have been for any particular question.
CSC 104 mid-term test #2
23 March 2012, 9:10 AM
No aids permitted.
Total: 20 marks.
Time allotted: 45 minutes.
Since time may be 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. [4 marks]
Write a python program which prompts for and inputs someone's name and age;
then if the age is 18, print "Happy birthday, name!", using the
name they specified.
(If the age is not exactly 18, there is no further output.)
print 'What is your name?' name = raw_input() print 'How old are you?' age = input() if age == 18: print 'Happy birthday,', name, '!'
2. [3 marks]
Write a spreadsheet formula which indicates whether cell D2 contains a passing
grade out of 100. Your formula should evaluate to 1 if the grade is a pass
(at least 50), or should evaluate to 0 if the grade is a failure.
3. [8 marks]
Write a python program which inputs two integers -- assume that the first
integer is less than the second -- and outputs all of the integers from the
first to the second, inclusive, one per line. For example, if the inputs are
3 and 5, your output would be
3 4 5You do not need to prompt for the inputs.
x = input() y = input() for i in range(x, y+1): print i
4. [5 marks]
a) What is the difference between <title> and <h1> in HTML?
State briefly what each one means.
b) The "<u>" tag in HTML indicates that the enclosed text should be underlined. How does this differ from the "<a>" tag, which also seems to underline the enclosed text? (In assignment three, we used <a> but did not use <u>.)
b) <a> (with "href=") is used to create a "hyperlink", where selecting the indicated text causes you to be presented with another document. The web browser will do something to indicate that the text is selectable, which is typically underlining, but that's not the main point, and it doesn't have to be underlining. On the other hand, <u> is just about underlining and does not make the text into a "hyperlink".