Show List

Quiz - Python - 3

72%

Public Average Score
Select the right answer for below questions:

What is the correct syntax to define a function in Python?
define function(args):
function(args) = { }
def function(args):
function args { }
def function(args):

What is the output of the following code:
x = [1, 2, 3, 4, 5]
print(x[2])
4
5
3
2
3

What is the correct way to check if a list is empty in Python?
len(list) == 0
list == []
list.empty()
not list
list == []

What is the correct way to add an element to a list in Python?
add(element)
list.add(element)
list[len(list)] = element
list.append(element)
list.append(element)

What is the output of the following code:
x = 7
y = 8
print(x + y)
15
14
13
12
15

What is the correct way to create a dictionary in Python?
dict = {key: value}
dict = [key: value]
dict {key: value}
dict = (key: value)
dict = {key: value}

What is the correct syntax for a for loop in Python?
for x in range(5)
for x in 5
for x in [0, 1, 2, 3, 4]
for x in range(5):
for x in range(5):

What is the correct way to access a value from a list in Python?
list.value(index)
list[index]
list.get(index)
list.index(value)
list[index]

What is the output of the following code:
x = "Hello, World!"
print(len(x))
12
13
14
15
13

What is the correct way to create a set in Python?
set = {1, 2, 3, 4, 5}
set = [1, 2, 3, 4, 5]
set [1, 2, 3, 4, 5]
set(1, 2, 3, 4, 5)
set = {1, 2, 3, 4, 5}

Submit
Retry
{"qz1-233692":"def function(args):","qz1-233693":"3","qz1-233694":"list == []","qz1-233695":"list.append(element)","qz1-233696":"15","qz1-233697":"dict = {key: value}","qz1-233698":"for x in range(5):","qz1-233699":"list[index]","qz1-233700":"13","qz1-233701":"set = {1, 2, 3, 4, 5}"}

    Leave a Comment


  • captcha text