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?
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
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?
8. Which operator is used to compare two numbers for equality?
9. How can we add two strings together?
C. s = s + s2
D. s ++ s2
10. How can we create a newline in a print function?
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).