Python - Skill Assignment Quiz
Q1. What is an abstract class?
- An abstract class is the name for any class from which you can instantiate an object.
- Abstract classes must be redefined any time an object is instantiated from them.
- Abstract classes must inherit from concrete classes.
- An abstract class exists only so that other "concrete" classes can inherit from the abstract class.
Q2. What happens when you use the build-in function any() on a list?
- The
any()
function will randomly return any item from the list. - The
any()
function returns True if any item in the list evaluates to True. Otherwise, it returns False. - The
any()
function takes as arguments the list to check inside, and the item to check for. If "any" of the items in the list match the item to check for, the function returns True. - The
any()
function returns a Boolean value that answers the question "Are there any items in this list?"
Q3. What data structure does a binary tree degenerate to if it isn't balanced properly?
- linked list
- queue
- set
- OrderedDict
Q4. What statement about static methods is true?
- Static methods are called static because they always return
None
. - Static methods can be bound to either a class or an instance of a class.
- Static methods serve mostly as utility methods or helper methods, since they can't access or modify a class's state.
- Static methods can access and modify the state of a class or an instance of a class.
Q5. What built-in list method would you use to remove items from a list?
-
.delete()
method -
pop(my_list)
-
del(my_list)
-
.pop()
method
Q6. What is one of the most common use of Python's sys library?
- to capture command-line arguments given at a file's runtime
- to connect various systems, such as connecting a web front end, an API service, a database, and a mobile app
- to take a snapshot of all the packages and libraries in your virtual environment
- to scan the health of your Python ecosystem while inside a virtual environment
Q7. What built-in Python data type is commonly used to represent a stack?
-
set
-
list
-
None
-
dictionary
-
You can only build a stack from scratch.
Q8. What built-in Python data type is commonly used to represent a stack?
- You can assign a name to each of the
namedtuple
members and refer to them that way, similarly to how you would access keys indictionary
. - Each member of a namedtuple object can be indexed to directly, just like in a regular
tuple
. -
namedtuples
are just as memory efficient as regulartuples
. - No import is needed to use
namedtuples
because they are available in the standard library.
Q9. What built-in Python data type is commonly used to represent a stack?
- Instance methods can modify the state of an instance or the state of its parent class.
- Instance methods hold data related to the instance.
- An instance method is any class method that doesn't take any arguments.
- An instance method is a regular function that belongs to a class, but it must return
None
.
Q10. Which statement does NOT describe the object-oriented programming concept of encapsulation?
- It protects the data from outside interference.
- A parent class is encapsulated and no data from the parent class passes on to the child class.
- It keeps data and the methods that can manipulate that data in one place.
- It only allows the data to be changed by methods.
Q11. What is the purpose of an if/else statement?
- It tells the computer which chunk of code to run if the instructions you coded are incorrect.
- It runs one chunk of code if all the imports were successful, and another chunk of code if the imports were not successful.
- It executes one chunk of code if a condition is true, but a different chunk of code if the condition is false.
- It tells the computer which chunk of code to run if the is enough memory to handle it, and which chunk of code to run if there is not enough memory to handle it.
Q12. What built-in Python data type is best suited for implementing a queue?
- dictionary
- set
- None. You can only build a queue from scratch.
- list
Q13. What built-in Python data type is best suited for implementing a queue?
-
my_game = class.Game()
-
my_game = class(Game)
-
my_game = Game()
-
my_game = Game.create()
Q14. What does the built-in map() function do?
- It creates a path from multiple values in an iterable to a single value.
- It applies a function to each item in an iterable and returns the value of that function.
- It converts a complex value type into simpler value types.
- It creates a mapping between two different elements of different iterables.
Q15. If you don't explicitly return a value from a function, what happens?
- The function will return a RuntimeError if you don't return a value.
- If the return keyword is absent, the function will return
None
. - If the return keyword is absent, the function will return
True
. - The function will enter an infinite loop because it won't know when to stop executing its code.
Q16. What is the purpose of the pass statement in Python?
- It is used to skip the
yield
statement of a generator and return a value of None. - It is a null operation used mainly as a placeholder in functions, classes, etc.
- It is used to pass control from one statement block to another.
- It is used to skip the rest of a
while
orfor loop
and return to the start of the loop.
Q17. What is the term used to describe items that may be passed into a function?
- arguments
- paradigms
- attributes
- decorators
Q18. Which collection type is used to associate values with unique keys?
-
slot
-
dictionary
-
queue
-
sorted list
Q19. When does a for loop stop iterating?
- when it encounters an infinite loop
- when it encounters an if/else statement that contains a break keyword
- when it has assessed each item in the iterable it is working on or a break keyword is encountered
- when the runtime for the loop exceeds O(n^2)
Q20. Assuming the node is in a singly linked list, what is the runtime complexity of searching for a specific node within a singly linked list?
- The runtime is O(n) because in the worst case, the node you are searching for is the last node, and every node in the linked list must be visited.
- The runtime is O(nk), with n representing the number of nodes and k representing the amount of time it takes to access each node in memory.
- The runtime cannot be determined unless you know how many nodes are in the singly linked list.
- The runtime is O(1) because you can index directly to a node in a singly linked list.
Q21. What is runtime complexity of the list's built-in .append() method?
- O(1), also called constant time
- O(log n), also called logarithmic time
- O(n^2), also called quadratic time
- O(n), also called linear time
Q22. What is runtime complexity of the list's built-in .append() method?
- O(1), also called constant time
- O(log n), also called logarithmic time
- O(n^2), also called quadratic time
- O(n), also called linear time
Q23. What is key difference between a set and a list?
- A set is an ordered collection unique items. A list is an unordered collection of non-unique items.
- Elements can be retrieved from a list but they cannot be retrieved from a set.
- A set is an ordered collection of non-unique items. A list is an unordered collection of unique items.
- A set is an unordered collection unique items. A list is an ordered collection of non-unique items.
Q24. What is the definition of abstraction as applied to object-oriented Python?
- Abstraction means that a different style of code can be used, since many details are already known to the program behind the scenes.
- Abstraction means the implementation is hidden from the user, and only the relevant data or information is shown.
- Abstraction means that the data and the functionality of a class are combined into one entity.
- Abstraction means that a class can inherit from more than one parent class.
Q25. What does calling namedtuple on a collection type return?
- a generic object class with iterable parameter fields
- a generic object class with non-iterable named fields
- a tuple subclass with non-iterable parameter fields
- a tuple subclass with iterable named fields
Q26. What symbol(s) do you use to assess equality between two elements?
-
&&
-
=
-
==
-
||
Q27. What does it mean for a function to have linear runtime?
- You did not use very many advanced computer programming concepts in your code.
- The difficulty level your code is written at is not that high.
- It will take your program less than half a second to run.
- The amount of time it takes the function to complete grows linearly as the input size increases.
Q28. Describe the functionality of a deque.
- A deque adds items to one side and remove items from the other side.
- A deque adds items to either or both sides, but only removes items from the top.
- A deque adds items at either or both ends, and remove items at either or both ends.
- A deque adds items only to the top, but remove from either or both sides.
Q29. When would you use a for loop?
- Only in some situations, as loops are used only for certain type of programming.
- When you need to check every element in an iterable of known length.
- When you want to minimize the use of strings in your code.
- When you want to run code in one file for a function in another file.
Q30. Which statement accurately describes how items are added to and removed from a stack?
- a stacks adds items to one side and removes items from the other side.
- a stacks adds items to the top and removes items from the top.
- a stacks adds items to the top and removes items from anywhere in the stack.
- a stacks adds items to either end and removes items from either end.
Q31. What is the correct way to run all the doctests in a given file from the command line?
-
python3 -m doctest <_filename_>
-
python3 <_filename_>
-
python3 <_filename_> rundoctests
-
python3 doctest
Q32. What is a lambda function ?
- any function that makes use of scientific or mathematical constants, often represented by Greek letters in academic writing
- a function that get executed when decorators are used
- any function whose definition is contained within five lines of code or fewer
- a small, anonymous function that can take any number of arguments but has only expression to evaluate
Q33. What is the difference between class attributes and instance attributes?
- Instance attributes can be changed, but class attributes cannot be changed
- Class attributes are shared by all instances of the class. Instance attributes may be unique to just that instance
- There is no difference between class attributes and instance attributes
- Class attributes belong just to the class, not to instance of that class. Instance attributes are shared among all instances of a class
Q34. Describe the functionality of a queue?
- A queue adds items to either end and removes items from either end.
- A queue adds items to the top and removes items from the top.
- A queue adds items to the top, and removes items from anywhere in, a list.
- A queue adds items to the top and removes items from anywhere in the queue.
Q35. When would you use a while loop?
- when you want to minimize the use of strings in your code
- when you want to run code in one file while code in another file is also running
- when you want some code to continue running as long as some condition is true
- when you need to run two or more chunks of code at once within the same file
Q36. What does the // operator in Python 3 allow you to do?
- Perform integer division
- Perform operations on exponents
- Find the remainder of a division operation
- Perform floating point division
Q37. What file is imported to use dates in python?
- datetime
- dateday
- daytime
- timedate
Q38. NumPy allows you to multiply two arrays without a for loop. This is an example of _.
- vectorization
- attributions
- accelaration
- functional programming
Q39. What built-in Python data type can be used as a hash table?
-
set
-
list
-
tuple
-
dictionary
Q40. it is often the case that the pandas library is used for _ data and NumPy for _ data.
- string; numerical
- unstructured; structured
- numerical; tabular
- tabular; numerical
Q41. What do you need to do to install additional packages into Python?
- Use a C compiler like gcc or clang.
- Use a package manager like pip or conda.
- Use an IDE like Notepad++ or Idle.
- Use a package manager like NPM or NuGet.
Q42. What is the maximum length of a Python identifier?
- 32
- 16
- 128
- No fixed length is specified
Q43. To use pipelines in scikit-learn, import from the scikit-learn._ submodule.
- preprocessing
- pipeline
- filters
- pipe_filter
READY TO GET STARTED?
Are you ready
Let’s Make Something Amazing Together



Need help? Contact our experts
Tell us about your project




