TORONTO KIDS COMPUTER CLUB | Aurora Wednesday 18:30 Python Practice – test
post-template-default,single,single-post,postid-18535,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 Wednesday 18:30 Python Practice – test

29 Oct Aurora Wednesday 18:30 Python Practice – test

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. 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)

3. 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

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

5. 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):

6. 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:

7. If you have a variable “example”, how do you check to see what type of
variable you are working with?
A. getType(example)
B. Type(example)
C. type(example)
D. example.type

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

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

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

11. 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).
No Comments

Sorry, the comment form is closed at this time.