a) var x = 5
b) x = 5
c) define x = 5
d) variable x = 5
Answer: b) x = 5
What function is used to round a decimal number in Python?
a) round_number()
b) round()
c) decimal_round()
d) number_round()
Answer: b) round()
What is the output of the following code:
print(5 + 3 * 2)
a) 11
b) 8
c) 16
d) 5
Answer: a) 11
What is the correct syntax for creating a list in Python?
a) list = [1, 2, 3]
b) [1, 2, 3]
c) array = [1, 2, 3]
d) {1, 2, 3}
Answer: b) [1, 2, 3]
How do you access the last element in a list in Python?
a) list[-1]
b) list[0]
c) list[end]
d) list[last]
Answer: a) list[-1]
What is the purpose of the ‘del’ keyword in Python?
a) To create a new variable
b) To delete a variable
c) To change the value of a variable
d) To rename a variable
Answer: b) To delete a variable
What is the output of the following code:
my_list = [1,2,3]
my_list.append(4)
print(my_list)
a) [1,2,3]
b) [4]
c) [1,2,3,4]
d) [1,2,3,4,5]
Answer: c) [1,2,3,4]
How do you remove a specific element from a list in Python?
a) list.remove()
b) list.pop()
c) list.erase()
d) list.delete()
Answer: a) list.remove()
How do you check if an element exists in a list in Python?
a) if element in list
b) list.contains(element)
c) if element exist in list
d) list.exists(element)
Answer: a) if element in list
What is the output of the following code:
my_list = [1, 2, 3, 4]
my_list[1:3] = [5,6]
print(my_list)
a) [1,5,6,4]
b) [1,2,5,6]
c) [1,2,3,4,5,6]
d) [5,6,3,4]
Answer: a) [1,5,6,4]
No comments:
Post a Comment