Linkedin Python Assessment Test Answers 2022

chase2learn.com
4 min readOct 19, 2022

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.
  • [x] An abstract class exists only so that other “concrete” classes can inherit from the abstract class.

reference

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.
  • [x] 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?”

example

Python

if any([True, False, False, False]) == True:print('Yes, there is True')>>> 'Yes, there is True'

Q3. What data structure does a binary tree degenerate to if it isn’t balanced properly?

  • [x] 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.
  • [x] 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.

reference

Q5. What are attributes?

  • [ ] Attributes are long-form version of an if/else statement, used when testing for equality between objects.
  • [x] Attributes are a way to hold data or describe a state for a class or an instance of a class.
  • [ ] Attributes are strings that describe characteristics of a class.
  • [ ] Function arguments are called “attributes” in the context of class methods and instance methods.

Explanation
Attributes defined under the class, arguments goes under the functions. arguments usually refer as parameter, whereas attributes are the constructor of the class or an instance of a class.

Q6. What is the term to describe this code?

count, fruit, price = (2, 'apple', 3.5)

  • [ ] tuple assignment
  • [x] tuple unpacking
  • [ ] tuple matching
  • [ ] tuple duplication

Q7. What built-in list method would you use to remove items from a list?

  • [ ] .delete() method
  • [ ] pop(my_list)
  • [ ] del(my_list)
  • [x] .pop() method

example

Python

my_list = [1,2,3]my_list.pop(0)my_list>>>[2,3]

Q8. What is one of the most common use of Python’s sys library?

  • [x] 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

Q9. What is the runtime of accessing a value in a dictionary by using its key?

  • [ ] O(n), also called linear time.
  • [ ] O(log n), also called logarithmic time.
  • [ ] O(n²), also called quadratic time.
  • [x] O(1), also called constant time.

Q10. What is the correct syntax for defining a class called Game, if it inherits from a parent class called LogicGame?

  • [x] class Game(LogicGame): pass
  • [ ] def Game(LogicGame): pass
  • [ ] def Game.LogicGame(): pass
  • [ ] class Game.LogicGame(): pass

Explanation: The parent class which is inherited is passed as an argument to the child class. Therefore, here the first option is the right answer.

Q11. What is the correct way to write a doctest?

  • [ ] A

Python

def sum(a, b):"""sum(4, 3)7sum(-4, 5)1"""return a + b
  • [x] B

Python

def sum(a, b):""">>> sum(4, 3)7>>> sum(-4, 5)1"""return a + b
  • [ ] C

Python

def sum(a, b):"""# >>> sum(4, 3)# 7# >>> sum(-4, 5)# 1"""return a + b
  • [ ] D

Python

def sum(a, b):###>>> sum(4, 3)7>>> sum(-4, 5)1###return a + b

Explanation — use ''' to start the doc and add output of the cell after >>>

for more questions and answer please visit

--

--

chase2learn.com

one place| Learn Gain Continue the Chase! Corner for CS, Software engineering, ML, AI, Software Developers, Programmers, CareerPath, Interviews questions.