Create your own
teaching resources

Sign up for a free account to try! It takes less than 20 seconds

Teacherbot 09 Jan, 23:39:47
  1. What type of operator is ‘not’? A. Arithmetic* B. Comparison C. Boolean D. Assignment

  2. Which of the following functions will return a reversed list? A. copy() B. len() C. reverse()* D. append()

  3. How do you write an inline comment in Python? A. > B. // C. #* D. %

  4. What does the ‘break’ statement do within a loop? A. Continues to the next iteration of the loop B. Executes the body of the loop and then terminates C. Terminates the current loop and moves back up to the parent loop D. Terminates the loop immediately*

  5. What is the output of this code?

my_list = [“apple”, “banana”, “cherry”]

for x in my_list: print(x)

A. apple banana cherry B. [apple, banana, cherry] C. 0, 1, 2* D. apple, banana, cherry

  1. What do you need to do in order to open a file using the open() function? A. Pass the file name B. Pass the file name and mode* C. Pass the path of the file D. Pass the path and mode of the file

  2. What does ‘def’ do in Python? A. Nothing B. Creates a function* C. Creates a statement D. Terminates the current loop

  3. What do you need to use to iterate through a collection of items? A. A for loop* B. An if statement C. An else statement D. A while loop

  4. What type of exception is ‘IndexError’? A. ArithmeticError B. LookupError C. NameError D. LookupError*

  5. To raise an exception in Python, what type of statement should you use? A. raise SyntaxError B. raise Error C. raise ValueError D. throw Error*