TORONTO KIDS COMPUTER CLUB | Aurora Tuesday 18:30 Python Test 22.03.08.
20387

# Aurora Tuesday 18:30 Python Test 22.03.08.

## 08 Mar Aurora Tuesday 18:30 Python Test 22.03.08.

```1.	Which of the following is NOT a correct variable name?
a)	heightOfTable2
b)	2tableHeight
c)	height_of_table2
d)	HeiGhtOf2TaBle

2.	Which of the following is correct answer to get the remainder for 8 / 3?
a)	8 // 3
b)	8 % 3
c)	8 mod 3
d)	int(8/3)

3.	Which of the following will get the integer result for 8 / 3?
a)	8 // 3
b)	int(8 / 3)
c)	8 / 3
d)	int(8) / int(3)
e)	a and b
f)	a, b and d

4.	If str1 = "12.3", which of the following is correct to convert str1 into integer?
a)	int(str1)
b)	int(float(str1))
c)	int(str(str1))
d)	input(int(str1))

5.	If food = "pizza", drink = "coke", which of the following statement will
get Syntax Error?
a)	print("I want", food, drink)
b)	print("I want " + food + drink)
c)	print("I want " + food, “and ” + drink)
d)	print("I want " food, drink)

6.	Which of the following statement is correct to check if a number was
greater than 30 but less than or equal to 40?
a)	if my_number > 30 and my_number < 40:
b)	if my_number > 30 && my_number <= 40:
c)	if my_number >= 30 and my_number <= 40:
d)	if my_number > 30 and my_number <= 40:

7.	How many "hello" would be printed out if the following loop run?

for i in range (1, 11, 2):
print (”hello”)

a)	11
b)	10
c)	5
d)	6

8.	What list of numbers would range(2, 8, 3) give you?
a)	2, 5
b)	2, 5, 8
c)	3, 5, 7
d)	2, 3, 4

9.	What’s the total number of stars that will be printed by the following code:

for i in range(5):
for j in range(3):
print ("*")

a)	8
b)	10
c)	12
d)	15

10.	If my_list = [1, 2, 3, 4, 5], which of the following is NOT correct to add
number 6 to my_list?
a)	my_list.append(6)
b)	my_list.insert(5, 6)
c)	my_list.extend()
d)	my_list.extend(6)

11.	If my_str = "hello world", which of the following is correct to get "lo wo"
from the string?
a)	my_str.substring(3, 8)
b)	my_str[4:9]
c)	my_str[3:8]
d)	my_str[3:9]

12.	Consider the following code segment.

a = 5
b = 2
c = 3.0
print(5 + a / b * c - 1)

What is printed when the code segment is executed?
a)	0.666666666666667
b)	9.0
c)	10.0
d)	11.5
e)	14.0

13.	Consider the processWords function. Assume that each of its two parameters
is a String of length two or more:
def processWords(word1, word2):
str1 = word1[0:2]
str2 = word2[:]
result = str2 + str1
print(result.index(str2))

Which of the following best describes the value printed when processWords is called?
a)	The value 0 is always printed.
b)	The value 1 is always printed.
c)	The value result.length() - 1 is printed.
d)	A substring containing the last character of word2 is printed.
e)	A substring containing the last two characters of word2 is printed.

```