What is the output of the following code?\n\nx = 5\nif x > 10:\n print('Hello')\nelse:\n print('World')
World
Hello
Error
None
Which of the following loops in Python is used to iterate over a sequence of elements?
For loop
While loop
Do-while loop
If-else loop
What is the correct syntax to define a function in Python?
Def function_name():
Function_name():
Function_name:
Define function_name():
What will be the output of the following code?\n\nmy_list = [1, 2, 3, 4, 5]\nprint(my_list[2])
3
1
2
4
Which of the following data types in Python is immutable?
Tuple
List
Dictionary
Set
What is the output of the following code?\n\ndictionary = {'name': 'John', 'age': 25}\nprint(dictionary['gender'])
KeyError
None
Error
'gender'
Which of the following is NOT a valid way to create an empty list in Python?
Empty_list = []
Empty_list = list()
Empty_list = ()
Empty_list = list([])
What is the output of the following code?\n\nx = 10\nwhile x > 0:\n print(x)\n x -= 2
What is the correct syntax to access the value associated with a specific key in a dictionary?
Dictionary_name[key]
Key[dictionary_name]
Dictionary_name.value(key)
Value(dictionary_name, key)
Which of the following is NOT a valid way to define a function in Python?
Def my_function():
My_function = lambda:
Def my_function(parameter):
Def my_function(parameter=default_value):
What will be the output of the following code?\n\nmy_tuple = (1, 2, 3)\nprint(my_tuple[1:])
(2, 3)
(1, 2, 3)
(1,)
(3,)
What will be the output of the following code?\n\nmy_tuple = (1, 2, 3)\nprint(my_tuple[1:])
(2, 3)
(1, 2, 3)
(1,)
(3,)
What is the correct syntax to add a key-value pair to an existing dictionary in Python?
Dictionary_name[key] = value
Dictionary_name.add(key, value)
Dictionary_name.append(key, value)
Dictionary_name.insert(key, value)
What will be the output of the following code?\n\nmy_list = [1, 2, 3]\nmy_list.append(4)\nprint(my_list)
[1, 2, 3, 4]
[4, 3, 2, 1]
[1, 2, 3]
[1, 2, 3, [4]]
What is the correct syntax to remove a specific key-value pair from a dictionary in Python?
Del dictionary_name[key]
Dictionary_name.remove(key)
Dictionary_name.pop(key)
Dictionary_name.delete(key)
What will be the output of the following code?\n\nx = 5\nwhile x > 0:\n print(x)\n if x == 3:\n break\n x -= 1
{"name":"What is the output of the following code?\\n\\nx = 5\\nif x > 10:\\n print('Hello')\\nelse:\\n print('World')", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"What is the output of the following code?\\n\\nx = 5\\nif x > 10:\\n print('Hello')\\nelse:\\n print('World'), Which of the following loops in Python is used to iterate over a sequence of elements?, What is the correct syntax to define a function in Python?","img":"https://www.poll-maker.com/3012/images/ogquiz.png?sz=1200-00000000001000005300"}
Make your own Survey
- it's free to start.