Skip to content
J2J Institute
Search
K
Main Navigation
Home
Jobs
Code here
Courses
Java
Core
Advanced
Python
SQL
PowerBI
Testing
Manual
Automation
Interview Questions
Java
Python
SQL
Manual
Automation
Quiz
Java
Python
SQL
Appearance
Menu
Return to top
On this page
Intermediate level python quiz
What will be the output of the following code: print([1, 2, 3] + [4, 5])?
[1, 2, 3, 4, 5]
[1, 2, 3][4, 5]
[1, 2, 3, [4, 5]]
Error
How can you check if a key exists in a dictionary in Python?
key in dict
dict.has_key(key)
key.contains(dict)
dict[key] exists
Which of the following is true about Python’s `global` keyword?
It allows you to modify a variable inside a function that is declared outside
It creates a new global variable
It prevents a variable from being modified inside a function
It makes a variable private
Which method is used to add an element at the end of a list in Python?
add()
insert()
append()
extend()
What will be the result of the following code: print('abc'.upper())?
ABC
abc
Error
None
Which function is used to sort a list in Python without modifying the original list?
sort()
sorted()
list.sort()
order()
What does the `enumerate()` function do in Python?
It adds an index to each item in an iterable
It filters out duplicate items from a list
It creates a list of tuples
It reverses the order of an iterable
What is the output of the following code: print(list(map(str, [1, 2, 3])))?
['1', '2', '3']
[1, 2, 3]
['1', 2, 3]
Error
What will be the output of the following code: print(3 * 'a' + 'b')?
'aaab'
'aab'
'aaa' + 'b'
Error
What is the purpose of the `@staticmethod` decorator in Python?
To define a method that does not operate on an instance of the class
To define a method that operates on an instance
To define a method that modifies a class variable
To define a method that cannot be called outside the class
Submit