T1 Homework 1
T1 Homework 1
1. State the values of a, b, c, d and e after the following operations are carried out: [5]
(a) a = 26 % 5= 1
(c) c = (7 + 3) * 4 – 1= 39
2. The function ASC('a') evaluates to 97, the ASCII value of the character ‘a’.
CHR(97) evaluates to 'a'.
State what is output by this algorithm: [4]
x = ord('b')
y = x + 1
z = x – 1
w = chr(y) + chr(z)
print(x)
print(y)
print(z)
print(w)
output=(98,99,97,‘ca’)
print(left)
print(right)
34
“please do n”
“the grass”
4. Write a comment for each line with a # after the code to explain its
purpose. [4]
[Total 16 marks]