Advanced Programming for Data Science Quiz
1. What is Object-oriented programming (OOP) primarily focused on?
a. Structuring a program by separating properties and behaviors
b. Structuring a program by bundling related properties and behaviors into objects
c. Structuring a program by categorizing properties and behaviors
d. Structuring a program by duplicating properties and behaviors
2. Which of the following is NOT an example of a class?
a. Email
b. Person
c. Animal
d. Car
3. What is a Class in Python?
a. A type of instance
b. A method for defining objects
c. A special data type defining how to build a particular object
d. An object that inherits from another class
4. Which of the following is an OOP concept?
a. Functions
b. Classes
c. Variables
d. Loops
5. What must be included as the first argument in all method definitions
in Python classes?
a. cls
b. super
c. object
d. self
6. How are objects instantiated in Python classes?
a. By calling the object directly
b. By using the new keyword
c. By using the create method
d. By calling the class name with () notation
7. What is the purpose of the init method in Python classes?
a. To define the attributes of the object
b. To serve as a destructor for the class
c. To serve as a constructor for the class
d. To define the methods of the object
8. What does the self keyword represent in Python classes?
a. The current date and time
b. The object currently being created
c. The superclass of the object
d. The class itself
9. How does Python handle memory management for objects?
a. Automatically frees memory using destructors
b. Requires explicit deletion of objects
c. Utilizes manual memory allocation
d. Utilizes automatic garbage collection
10. What are the non-method data stored by objects called?
a. Functions
b. Arguments
c. Parameters
d. Attributes
11. Which type of attributes are shared by all instances of a class?
a. Data attributes
b. Temporary attributes
c. Dynamic attributes
d. Class attributes
12. How can unknown members of a class be accessed in Python?
a. Using the eval function
b. Using the getattr function
c. Using the fetch method
d. Using the access attribute
13. What is the capability of one class to derive properties from another
class called?
a. Inheritance
b. Incarnation
c. Association
d. Derivation
14. What does Python Polymorphism refer to?
a. Having unchangeable data types
b. Using the same function name for different types
c. Strict data typing requirements
d. Limited function calling
15. What does Python Encapsulation aim to prevent?
a. Accidental data corruption
b. Accidental data deletion
c. Accidental data duplication
d. Accidental data modification
16. How can a variable be defined as a protected variable in Python
classes?
a. By adding the @protected decorator
b. By appending a prefix of __
c. By using the private keyword
d. By defining it inside a method
17. What does a metaclass allow in Python?
a. Instantiation of classes as objects
b. Direct modification of class attributes
c. Dynamic creation of classes
d. Automatic inheritance of class attributes
18. Which keyword allows for accessing unknown members of a class in
Python?
a. access
b. fetch
c. getattr
d. unknown
19. What is the primary benefit of Python Inheritance?
a. Increased memory usage
b. Improved data security
c. Reusability of code
d. Decreased flexibility
20. What is the role of a class in Object-oriented programming?
a. Describes the relationships between objects
b. Defines the attributes and behaviors of objects
c. Instantiates objects directly
d. Executes the methods of objects
Answer Key (Always review AI generated answers for accuracy - Math is more likely to be
inaccurate)
1. b. Structuring a program by bundling related properties and behaviors into
objects
2. c. Animal
3. c. A special data type defining how to build a particular object
4. b. Classes
5. d. self
6. d. By calling the class name with () notation
7. c. To serve as a constructor for the class
8. b. The object currently being created
9. d. Utilizes automatic garbage collection
10. d. Attributes
11. d. Class attributes
12. b. Using the getattr function
13. a. Inheritance
14. b. Using the same function name for different types
15. a. Accidental data modification
16. b. By appending a prefix of __
17. c. Dynamic creation of classes
18. c. getattr
19. c. Reusability of code
20. b. Defines the attributes and behaviors of objects
1. What is the primary characteristic of Object-oriented programming (OOP)?
a. It primarily uses linear programming techniques
b. It structures a program by bundling related properties and behaviors into individual
objects
c. It relies heavily on functional programming paradigms
d. It does not support the concept of classes and objects
2. In Python, what is a decorator?
a. A keyword to define a new class
b. A function that changes the behavior of another function without modifying it explicitly
c. A data structure used to store multiple values of the same data type
d. An operator used for bitwise operations
3. What is the purpose of the str method in Python?
a. It returns a string representation of an object that is machine-readable
b. It defines the superclass of a class
c. It is used to calculate the length of a string
d. It returns a string representation of an object that is human-readable
4. What is a metaclass in Python?
a. A class that stores metadata information about other classes
b. A built-in class used for mathematical operations
c. A class that creates other classes
d. A class specifically used for debugging purposes
5. What is a generator in Python?
a. A Python library for generating random numbers
b. A function that returns an iterator using the Yield keyword
c. A class used for generating HTML code
d. A tool for creating graphical user interfaces
6. Which method is called first when creating a new object in Python?
a. call
b. new
c. init
d. create
7. What is the main advantage of using generators in Python?
a. They enhance code readability
b. They allow for better performance by not producing all values at once
c. They simplify exception handling
d. They increase the speed of code execution
8. What is a key characteristic of metaprogramming?
a. It focuses on the manipulation of data structures
b. It adds new features to existing classes at runtime
c. It involves creating programs that can generate or manipulate other programs
d. It is exclusive to functional programming languages
9. When should decorators be used in Python?
a. Only for basic arithmetic operations
b. To modify the behavior of functions without directly altering them
c. For creating class instances dynamically
d. For handling file I/O operations efficiently
10. What does the @ symbol signify in Python with respect to decorators?
a. It indicates a special data type
b. It is used to invoke generator functions
c. It marks the beginning of a comment
d. It is used to decorate a function
11. How does a generator function differ from a normal function in Python?
a. Generator functions always return None
b. Generator functions cannot accept arguments
c. Generator functions use the yield keyword to produce values
d. Generator functions are limited to a single return statement
12. Which special method in Python is responsible for creating a string
representation of an object?
a. display
b. format
c. str
d. print
13. What is the primary use of metaclasses in Python?
a. To define attributes of a class
b. To create classes dynamically
c. To provide additional security to classes
d. To overwrite built-in class methods
14. In the context of Python, what does the eq method handle?
a. Equality comparison between two objects
b. Evaluation of logical expressions
c. Execution of mathematical operations
d. Enumeration of class attributes
15. How do metaclasses impact the creation of classes in Python?
a. They allow classes to be imported from external sources
b. They modify the behavior or attributes of created classes
c. They enforce restrictions on class inheritance
d. They prevent the instantiation of classes
16. Which core Python class is associated with metaclasses?
a. object
b. meta
c. base
d. class
17. What programming concept does a decorator primarily focus on?
a. Encapsulation
b. Inheritance
c. Polymorphism
d. Functionality enhancement
18. What is the primary feature of a generator function in Python?
a. It returns a single predefined value
b. It can accept an unlimited number of arguments
c. It generates values on-the-fly using the yield keyword
d. It is limited to a specific data type
19. How do decorators contribute to code maintainability in Python?
a. They reduce the need for unit testing
b. They simplify the debugging process
c. They enforce strict typing rules
d. They enhance code reusability
20. Which of the following statements accurately represents a metaclass in
Python?
a. A metaclass defines the structure of an object's methods
b. A metaclass is used to represent static attributes of a class
c. A metaclass is a class that defines the behavior of other classes
d. A metaclass is primarily used for error handling
Answer Key (Always review AI generated answers for accuracy - Math is more likely to be
inaccurate)
1. b. It structures a program by bundling related properties and behaviors into
individual objects
2. b. A function that changes the behavior of another function without modifying it
explicitly
3. d. It returns a string representation of an object that is human-readable
4. c. A class that creates other classes
5. b. A function that returns an iterator using the Yield keyword
6. b. new
7. b. They allow for better performance by not producing all values at once
8. c. It involves creating programs that can generate or manipulate other programs
9. b. To modify the behavior of functions without directly altering them
10. d. It is used to decorate a function
11. c. Generator functions use the yield keyword to produce values
12. c. str
13. b. To create classes dynamically
14. a. Equality comparison between two objects
15. b. They modify the behavior or attributes of created classes
16. a. object
17. d. Functionality enhancement
18. c. It generates values on-the-fly using the yield keyword
19. b. They simplify the debugging process
20. c. A metaclass is a class that defines the behavior of other classes
Copy
Export
Read Aloud
More
Assessment on Debugging and Error Handling in Programming
1. What are the three groups in which programming errors can be
classified?
a. Syntax, Typeface, Logical
b. Syntax, Runtime, Logical
c. Syntax, Debugging, Logical
d. Syntax, Logical, Computational
2. When do Syntax errors occur in a program?
a. During compilation
b. While the program is running
c. After the program completes execution
d. Only in specific conditions
3. Which of the following is an example of a Syntax Error?
a. NameError
b. ZeroDivisionError
c. Indentation errors
d. KeyError
4. What type of errors occur while the program is running?
a. Syntax errors
b. Logical errors
c. Runtime errors
d. Debugging errors
5. Which of the following is an example of a Runtime Error?
a. IndexError
b. Missing semicolon
c. Indentation errors
d. Matching parenthesis
6. What are Logical Errors in programming?
a. Errors that occur during compilation
b. Errors with syntax of the code
c. Errors that cause the program to crash
d. Errors where the output is incorrect
7. How can exceptions be handled in Python?
a. Using conditional statements
b. Using try-except block
c. Ignoring them
d. Re-writing the code
8. What technique involves using print() to display variable values for
debugging?
a. Debugger
b. Error Messages
c. Reading the code
d. print statement
9. Which technique allows you to step through the code and inspect
variables?
a. Reading Error Messages
b. Using a Debugger
c. Try-except block
d. Debugging Techniques
10. What should you do to verify your program and find errors?
a. Run the program once
b. Write test cases
c. Debug the entire code
d. Ignore the errors
11. Which of the following is NOT a common Runtime Error?
a. FileNotFoundError
b. TypeError
c. IndexError
d. Missing colon
12. How can exceptions save you from lengthy if-else statements for
data validation?
a. By simplifying the code
b. By ignoring the errors
c. By creating more errors
d. By increasing the code complexity
13. What should you do to ensure there are no illogical errors in the
program?
a. Run the program once
b. Write test cases
c. Debug the entire code
d. Ignore the errors
14. What is the process of identifying and fixing errors in a program?
a. Reading Error Messages
b. Debugging
c. Handling exceptions
d. Verifying the program
15. How can you understand the flow of execution in a Python program?
a. Using print() statements
b. Ignoring errors
c. Writing more code
d. Running the program multiple times
16. What is the purpose of using a Debugger in programming?
a. To introduce errors
b. To simplify the code
c. To understand the flow of execution
d. To ignore Runtime Errors
17. Which of the following is NOT a common Syntax Error?
a. Missing colon
b. Indentation errors
c. TypeError
d. Matching parenthesis
18. What should be done before starting to write code to handle errors
effectively?
a. Design the solution
b. Ignore potential errors
c. Write the code quickly
d. Skip the planning phase
19. Which block of code allows you to handle exceptions in Python?
a. if-else block
b. for loop
c. try-except block
d. while loop
20. What does Input sanitization refer to in error handling?
a. Ensuring the code is properly indented
b. Handling exceptions using try-except blocks
c. Verifying the inputs before processing
d. Debugging the entire code
Answer Key (Always review AI generated answers for accuracy - Math is more likely to be
inaccurate)
1. b. Syntax, Runtime, Logical
2. a. During compilation
3. c. Indentation errors
4. c. Runtime errors
5. a. IndexError
6. d. Errors where the output is incorrect
7. b. Using try-except block
8. d. print statement
9. b. Using a Debugger
10. b. Write test cases
11. d. Missing colon
12. a. By simplifying the code
13. b. Write test cases
14. b. Debugging
15. a. Using print() statements
16. c. To understand the flow of execution
17. c. TypeError
18. a. Design the solution
19. c. try-except block
20. c. Verifying the inputs before processin
1. What is benchmarking in software development?
a. Testing software for bugs
b. Evaluating performance by measuring how it executes specific tasks
c. Designing user interfaces
d. Documenting code efficiently
2. Why is benchmarking code execution time important?
a. To increase costs
b. To improve performance
c. To minimize user experience
d. To reduce resources
3. What are the consequences of neglecting code execution time
benchmarking?
a. Improved performance
b. Efficient resource utilization
c. Poor user experience
d. Speed optimization
4. How can Python code be benchmarked using the "time" module?
a. time.pref_counter( )
b. executeTime.time( )
c. pythonBenchmark.timeCheck( )
d. checkTime.python( )
5. What does profiling provide insights into?
a. How to write code faster
b. How a program executes
c. User interface design
d. Debugging functionality
6. What does profiling tools gather data on?
a. Computer hardware
b. Various aspects of program execution
c. Internet connection speed
d. Software installation
7. Why is it beneficial to profile code?
a. Increase overhead
b. Enhance user experience
c. Cause inefficiency in code
d. Delay program execution
8. What is the primary objective of benchmarking?
a. Optimize program resources
b. Quantify the speed and efficiency of code execution
c. Extend program development time
d. Minimize code performance
9. How is benchmarking commonly used in code development?
a. To introduce bugs intentionally
b. To avoid testing
c. To compare different implementations
d. To ignore performance issues
10. What does profiling seek to identify in code behavior?
a. Efficient algorithms
b. Redundant operations
c. Resource consumption
d. User interface designs
11. Which data science library is fundamental for numerical computation in
Python?
a. tensorflow
b. numpy
c. pandas
d. matplotlib
12. What is scipy designed on top of?
a. tensorflow
b. numpy
c. keras
d. pandas
13. What is the primary purpose of the pandas library?
a. Data analysis and cleaning
b. Machine learning
c. Deep learning
d. Visualization
14. What is the main focus of the matplotlib library?
a. Numerical computation
b. Data analysis
c. Visualization
d. Machine learning
15. Which library is known as a machine learning library?
a. pandas
b. matplotlib
c. scikit-learn
d. keras
Answer Key (Always review AI generated answers for accuracy - Math is more likely to be
inaccurate)
1. b. Evaluating performance by measuring how it executes specific tasks
2. b. To improve performance
3. c. Poor user experience
4. a. time.pref_counter( )
5. b. How a program executes
6. b. Various aspects of program execution
7. b. Enhance user experience
8. b. Quantify the speed and efficiency of code execution
9. c. To compare different implementations
10. c. Resource consumption
11. b. numpy
12. b. numpy
13. a. Data analysis and cleaning
14. c. Visualization
15. c. scikit-learn