Team 1
Team 2
Team 3
Team 4
Team 5
100

How do you insert comments in Python code?

  • a) # This is a comment
  • b) // This is a comment
  • c) /* This is a comment */
  • d) <!-- This is a comment -->

a) # This is a comment

100

What is the correct file extension for Python files?

  • a) .pyth
  • b) .pt
  • c) .py
  • d) .pyt

c) .py

100

Which one is a correct variable assignment in Python?

  • a) var x = 5
  • b) x <- 5
  • c) x = 5
  • d) int x = 5

c) x = 5

100

How do you create a function in Python?

  • a) def myFunction():
  • b) function myFunction()
  • c) create myFunction()
  • d) myFunction function()
a) def myFunction():
100

How do you call a function in Python named 'myFunction'?

  • a) call myFunction()
  • b) myFunction()
  • c) execute myFunction()
  • d) run myFunction()

b) myFunction()

200

Which of the following is a correct way to create a list in Python?

  • a) myList = {}
  • b) myList = ()
  • c) myList = []
  • d) myList = ||

c) myList = []

200

What is the correct way to create a dictionary in Python?

  • a) myDict = {}
  • b) myDict = []
  • c) myDict = ()
  • d) myDict = ||

a) myDict = {}

200

Which method can be used to return the length of a list?

  • a) len()
  • b) length()
  • c) count()
  • d) size()

a) len()

200

How do you check for equality in Python?

  • a) =
  • b) ==
  • c) ===
  • d) !=

b) ==

200

Which of the following is a correct if statement in Python?

  • a) if x == y:
  • b) if x = y
  • c) if (x == y)
  • d) if x equal y:

a) if x == y:

300

How do you insert an element at the end of a list in Python?

  • a) myList.add("element")
  • b) myList.append("element")
  • c) myList.insert("element")
  • d) myList.addLast("element")

b) myList.append("element")

300

What is the correct way to import a module named 'math'?

  • a) import math
  • b) include math
  • c) using math
  • d) require math

a) import math

300

How do you check if a list contains a specific element in Python?

  • a) if "element" in myList:
  • b) if myList.has("element"):
  • c) if "element" contains myList:
  • d) if "element" in myList

a) if "element" in myList:

300

How can you remove an element from a list?

a) myList.remove(1)

b) myList().remove("element")

c) myList().pop(1)

d) myList.remove("element")

d) myList.remove("element")

300

Which of the following is not a correct if statement in Python?

  • a) if x == y:
  • b) if x = y:
  • c) if x >= y
  • d) if x != y:

b) if x = y:

400

What will be the output of the following code? 

def func(a, b=5, c=10):    

      print(a, b, c) 

func(1, c=20)

  • a) 1 5 10
  • b) 1 20 10
  • c) 1 5 20
  • d) 1 20 5

c) 1 5 20

400

What is the output of the following code?

my_list = [1, 2, 3, 4]
print(my_list[1])

  • a) 1
  • b) 2
  • c) 1, 2, 3, 4
  • d) [1, 2]

b) 2

400

Identify the error in the following code:

def divide(a, b):    

     return a / b

print(divide(10, 0))


ZeroDivisionError

400

Identify the error in the following code:

fruits = ["apple", "banana", "cherry"]
print(fruits[3])


IndexError

400

Identify the error in the following code:

for i in range(10):
print(i * 2)


IndentationError / Spacing Error

500

What's the error in this code:

while True    
        print("Infinite loop")

SyntaxError / missing ":"

500

What's the error in this code:

my_list = [1, 2, 3]
my_list.append(4, 5)
print(my_list)


TypeError /
append() can be given just 1 argument rather than 2

500

What's the error in this code:

x = "Hello"
y = 5
print(x + y)

TypeError
You can't concatenate strings and integers

500

What's the error in this code:

def square(number):    
     return number ** 2
result = square[5]
print(result)

square is a function not a list

() should be used instead of []

500

What does the following list comprehension return?

[x**2 for x in range(1,5) if x % 2 == 0]

  • a) [0, 1, 4, 9, 16]
  • b) [1, 4, 16]
  • c) [4, 16]
  • d) [0, 2, 4]

c) [4, 16]

M
e
n
u