,1. Multiple Choice: What is the output of the following Python
code snippet?
```python
list = ['a', 'b', 'c', 'd']
print("".join(list[::2]))
```
A) ac
B) bd
C) abc
D) None of the above
Correct Answer: A) ac
Rationale: The slicing `list[::2]` takes every second element from
the list starting from the first element. Therefore, it takes 'a' and
'c'.
2. Fill-in-the-Blank: An ________ search algorithm is more
efficient than a linear search algorithm for sorted lists.
Correct Answer: Binary
, Rationale: A binary search algorithm divides the list in half each
time, which makes it more efficient for sorted lists compared to a
linear search that checks each element sequentially.
3. True/False: In object-oriented programming, encapsulation is
not useful for hiding the internal state of an object.
Correct Answer: False
Rationale: Encapsulation is a fundamental concept in object-
oriented programming that is used to hide the internal state of an
object and expose only necessary parts through an interface.
4. Multiple Response: Which of the following are principles of
Object-Oriented Programming?
A) Inheritance
B) Encapsulation
C) Polymorphism
D) Recursion
Correct Answers: A) Inheritance, B) Encapsulation, C)
Polymorphism
Rationale: Inheritance, encapsulation, and polymorphism are all
key principles of object-oriented programming. Recursion is a
programming technique, not a principle of OOP.
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller EmilioOchieng. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for £12.66. You're not tied to anything after your purchase.