Python Quiz PDF
Document Details

Uploaded by AdroitSpinel6825
Tags
Summary
This document contains a series of multiple-choice questions about Python data structures, functions, and programming objects. The quiz covers concepts like lists, tuples, sets, dictionaries, and object-oriented design concepts.
Full Transcript
Q11 What is the purpose of Abstraction in OOP? SCORE To increase the visibility of internal details of a class. v...
Q11 What is the purpose of Abstraction in OOP? SCORE To increase the visibility of internal details of a class. v To hide implementation details and show only essential features. 1 To define multiple forms of a method. To inherit features from another class. Add Explanation Q12 What is the difference between an abstract class and an interface in OOP? SCORE V An abstract class can have implemented methods, but an interface cannot. 1 An interface can be instantiated, but an abstract class cannot. An interface can have private methods, but an abstract class cannot. There is no difference; both are identical. Add Explanation Q3 Tuples can only store elements of the same data type. SCORE True v False Add Explanation Q4 Which Python data type is best suited for storing unique, unordered items? SCORE List Tuple Set 1 Dictionary Add Explanation Q7 Which of the following is true about Python dictionaries? SCORE They are immutable. Keys can have duplicates. Values can have duplicates. 1 Keys must be strings. Add Explanation Q8 Which of the following statements is true about Python functions? SCORE A function must always have a return statement. A function can have multiple return statements. 1 A function cannot have default arquments. A function must always have parameters. Add Explanation How do you add an item to a list in Python? ScORE list.add(item) v list.append(item) list.push(item) list.insert(item) Add Explanation Q2 Why shouldn't you name your Python variable str? SCORE It makes the code angry. The code becomes self-aware. v You'll accidentally shadow the built-in str type, and Python will give you the silent treatment. The variable will turn into a snake. Add Explanation What does the following code print? SCORE Division by zero! End of program. Error End of program. None of the above Add Explanation Q10 Which of the following is/are a principle of Object-Oriented Programming? SCORE v Add score if only correct answers are selected 1 Add penalty if any incorrect answers are selected Encapsulation 0 Inheritance Polymorphism Compilation Add Explanation