Home > Python > Quizzes > Python Core Quiz
Python Core Quiz
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 30% Most missed: “What signal detection statement could stop an iterator from executing more than …”

For Pluralsight Skill Assessments.

Python Core Quiz
Time left 00:00
18 Questions

1. How can you create a global variable in Python?
2. What print function do you use to print out 'Casey'?
employee={ 'firstname': 'Casey', 'lastname': 'Smith','age':43, 'hobbies': 'tennis'}
3. You have a package that is developed on a different location from the default location. How can you make sure every time you open the shell, the package can be imported?
4. What shows the proper use of length?
5. What built-in function can operate on any iterable type and be used to filter what is passed to it?
6. How to do a most efficient multiply function with two arguments as numbers?
7. What is the purpose of the continue statement inside a loop?
8. What signal detection statement could stop an iterator from executing more than seven times?
9. You're given the following directory tree:
dir
|
+-- my_script. py
|
+-- package
|
+-- _init_.py
|
+-- subpackage
|
+-- _init_.py
|
+-- module.py
What import statement would you use to import function1 located in module.py ?
10. You must review some code for a Python script designed to gather information from end users. What is the problem with the following code?
var = 1
while var == num = raw_input('Enter a number :')
print 'You entered: ', num
11. What is the difference between a mutable and an immutable object?
12. What is an example of a relational operator?
13. You use a custom context manager for the with statement to open a file. You run the code, but the file is still open. What can solve it?
class customContext:
def __init__(myfile,name):
myfile.name=name
def __enter__(myfile):
myfile.file=open(myfile.name, 'r')
return myfile.file
def __exit__(myfile):
if myfile.file:
14. What function can find the list size?
15. You are a data engineer working on a project that calculates oil pipeline revenues using Python for large data sets. In your code, you have a tuple that contains the current price for oil for different geographic areas. You wrote a function that will update this tuple when oil prices change for that area, however you are getting errors in Python when the function executes. What is the likely cause of this error?
16. Using a built-in Python function, what code option finds the distance from zero of the value of y?
17. Which method must you define for an iterable object?
18. When using contextmanager from contextlib module, what decorator do you use?