Home > Python > Quizzes > Python Programming Quiz
Python Programming Quiz
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 14% Most missed: “What does this function print?”

Python MCQs For LinkedIn Skill Assessments.

Python Programming Quiz
Time left 00:00
25 Questions

1. Suppose you have a string variable defined as y=”stuff;thing;junk;”. What would be the output from this code?
python
z = y.split(‘;’)
len(z)
2. What would this expression return?
python
college_years = ['Freshman', 'Sophomore', 'Junior', 'Senior']
return list(enumerate(college_years, 2019))
3. Pick correct representation of doctest for function in Python.
4. When would you use a try/except block in code?
5. Why is it considered good practice to open a file from within a Python script by using the 'with' keyword?
6. What statement about the class methods is true?
7. Which statement does NOT describe the object-oriented programming concept of encapsulation?
8. What is a lambda function ?
9. According to the PEP 8 coding style guidelines, how should constant values be named in Python?
10. When an array is large, NumPy will not print the entire array when given the built-in 'print' function. What function can you use within NumPy to force it to print the entire array?
11. What are the two main data structures in the Pandas library?
12. What is the correct syntax for creating a variable that is bound to a set?
13. Why would you use a decorator?
14. What is the output of this code?
python
def myFunction(country = 'France'):
print('Hello, I am from', country)
myFunction('Spain')
myFunction('')
myFunction()
15. What is the runtime complexity of adding an item to a stack and removing an item from a stack?
16. What is the correct way to write a doctest?
17. What will this statement return?
python
{x : x*x for x in range(1,100)}
18. Review the code below. What is the correct syntax for changing the price to 1.5?
python
fruit_info = {
'fruit': 'apple',
'count': 2,
'price': 3.5
}
19. What is the runtime complexity of searching for an item in a binary search tree?
20. What is the term used to describe items that may be passed into a function?
21. Which statement accurately describes how items are added to and removed from a stack?
22. What does a class's '__init__()' method do?
23. If you don't explicitly return a value from a function, what happens?
24. In Python, when using sets, you use '\_' to calculate the intersection between two sets and '
\_' to calculate the union.
25. Why would you use a virtual environment?