TORONTO KIDS COMPUTER CLUB | Aurora Tuesday 10:30 Python Test 21.08.10.
19797
post-template-default,single,single-post,postid-19797,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.8.0,vc_responsive

Aurora Tuesday 10:30 Python Test 21.08.10.

10 Aug Aurora Tuesday 10:30 Python Test 21.08.10.

1. What is the output of print mystr * 2 if mystr = 'Hello World!'?
A. Hello World * 2
B. Hello World! Hello World!
C. Hello Hello
D. mystr mystr

2. Which of the following function gets the length of the string?
A. isupper()
B. join(seq)
C. len(string)
D. ljust(width[, fillchar])

3. How would you cast the string variable “a” that is equal to “2” into the integer 2?
A. castToInt(a)
B. int(a)
C. integer(a)
D. castToInteger(a)

4. Which one of the following is a valid Python if statement
A. if a >= 22:
B. if (a >= 22)
C. if (a => 22)
D. if a >= 22

5. What keyword would you use to add an alternative condition to an if statement?
A. else if
B. elseif
C. elif
D. None of the above

6. Which of the following is a valid for loop in Python?
A. for(a = 0; a < 3; a++)
B. for a in range(3)
C. for a loop 3:
D. for a in range(1,3):

7. Which of the following is a valid way to start a while loop in Python?
A. while loop a < 10
B. while a < 10:
C. while(a < 10)
D. while loop a < 10:

8. Which of the following is a valid list in Python?
A. sampleList = {1,2,3,4,5}
B. sampleList = (1,2,3,4,5)
C. sampleList = /1,2,3,4,5/
D. sampleList = [1,2,3,4,5]

9. How would you print the second item in the list variable “example”?
A. print(example[2])
B. echo(example[2])
C. print(example[1])
D. print(example(2))

10. Which operator is used to compare two numbers for equality?
A. =
B. ==
C. !=
D. +=

11. How can we add two strings together?
A. s.join(s2)
B. s.add(s2)
C. s = s + s2
D. s ++ s2

12. How can we create a newline in a print function?
A. \\
B. \"
C. \t
D. \n

13. Write a program which will find all such numbers which are divisible by 7 but are not
a multiple of 5, between 2000 and 3200 (both included).


14. Vehicles are classified based on their total interior volume. The classify function
is intended to return a vehicle classification String value based on total interior volume,
in cubic feet, as shown in the table below:

Vehicle size class

Total interior volume

Minicompact

Less than 85 cubic feet

Subcompact

85 to 99 cubic feet

Compact

100 to 109 cubic feet

Mid-Size

110 to 119 cubic feet

Large

120 cubic feet or more


Please continue write the program as following:
def classify(volume):

No Comments

Sorry, the comment form is closed at this time.