CSC1010H ClassTest1 2024 Revised
CSC1010H ClassTest1 2024 Revised
Class Test 1
Wednesday, 8 May 2024
Marks: 35 · Approximate marks per question are
shown in brackets
Time: 40 minutes · The use of calculators is permitted
Surname Initials
NAME:
This paper consists of 7 questions and 6 pages (including this cover page).
Mark Allocation
Question Marks Internal External Question Marks Internal External
1 5 6 6
2 5 7 5
3 6
4 4
5 4
Total Total
Grand Total
Final Mark
Internal Examiner: External Examiner:
Question 1. [5 marks]
For each of the following, say whether the statement is True or False.
[1]
[1]
[1]
[1]
e) For the variable mentioned in the previous question what is the index number of “i”
[1]
Question 2. [5 marks]
a) divmod(60,7) [1]
b) 7*2**3+5//2 [1]
[1]
Question 3. [6 marks]
a) def main():
turtle.shape("turtle")
turtle.mode("logo")
turtle.title("Right")
turtle.right(45)
turtle.forward(50)
turtle.right(90)
turtle.froward(50)
turtle.exitonclick()
main()
Find the problems in the given code
[2]
b) w=4
for i in range(1, w + 1):
p = “ ” * (w - i)
s = “**” * i
print(p + s)
Please provide the expected output produced by the given Python code.
[4]
Question 4. [4 marks]
For the given variables write the code to get the following output.
**Expecto** Patronum$$$$
[2]
Write down the Python code to manipulate the given variable so that the output looks like the
following-
[1]
[1]
Question 5. [4 marks]
[4]
Question 6. [6 marks]
[3]
[3]
Question 7. [5 marks]
Write a Python program that prompts the user to enter a number until the user types “done”. For each
number entered, if it is greater than 20, the program should ignore it and prompt for another number. If
the number is negative, the program should instruct the user to enter a positive number instead. The
program should multiply together all other valid numbers entered by the user, and display the result of
this multiplication. Users may enter floating-point numbers, but the final output of the multiplication
should be displayed as an integer.
[5]