Test1 v1
Test1 v1
Marking Guide
No 1: / 2
No 2: / 2
• This test consists of 6 questions on 8 pages (including this one), printed on both
sides of the paper. When you receive the signal to start, please make sure that No 3: / 7
your copy of the test is complete.
No 4: / 3
• Answer each question directly on the test paper, in the space provided.
No 5: / 2
No 6: / 6
TOTAL: /22
XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX Winter 2023 Midterm Test
csc108h1-winter-2023-v1-midterm CSC 108 H1S
#999 2 of 8 Duration: 50 minutes
2 == 2 or 2/0 == 0
'p' in 'APPLE'
count = 10
while count > 0:
print("hello")
count = count - 5
s = 'bumbly mia'
i = len(s) - 1
n = 2
while i > 0:
print(s[i])
i = i - n
Winter 2023 Midterm Test XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
CSC 108 H1S csc108h1-winter-2023-v1-midterm
Duration: 50 minutes #999 3 of 8
1 def midterm_function_a ( ) :
2 " " " Used t o t e s t u n d e r s t a n d i n g
3 o f how i f s t a t e m e n t s a r e e x e c u t e d .
4 """
5 k = 'z '
6
7 i f k != ' e ' :
8 k = 'e ' Breakpoint before line 8: k ‘z’
9 else :
10 k = 'i ' Breakpoint before line 10: k
11
12 i f k == ' e ' :
13 k = '? ' Breakpoint before line 13: k
14
15 k = 'w ' Breakpoint before line 15: k
16
17 def midterm_function_b ( ) :
18 " " " Used t o t e s t u n d e r s t a n d i n g
19 o f how i f s t a t e m e n t s a r e e x e c u t e d .
20
21 This d o c s t r i n g doesn ' t d e s c r i b e
22 t h e r e t u r n v a l u e . Bad s t y l e !
23 : −)
24 """
25 k = 'z '
26
27 i f k == ' e ' :
28 return k Breakpoint before line 28: k
29 else :
30 k = 'i ' Breakpoint before line 30: k
31
32 k = 'w ' Breakpoint before line 32: k
Winter 2023 Midterm Test XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
CSC 108 H1S csc108h1-winter-2023-v1-midterm
Duration: 50 minutes #999 5 of 8
index = 0
contains = False
if s[index].isdigit():
contains = True
index += 1
return contains
def get_non_digits(
"""
>>> get_non_digits('mia')
'mia'
>>> get_non_digits('123bumbly!!456')
'bumbly!!'
>>> get_non_digits('CSC108 is #1')
'CSC is #'
>>> get_non_digits('012345')
''
"""
new =
for :
return
XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
UNIVERSITY OF TORONTO csc108h1-winter-2023-v1-midterm
Faculty of Arts & Science #999 7 of 8
Winter 2023 Term Test 1
[Use the space below for rough work. This page will not be marked unless you clearly indicate the part of your
work that you want us to mark.]