Assignment 3(1)

.docx

School

University of Texas, Dallas *

*We aren’t endorsed by this school

Course

4381

Subject

Computer Science

Date

May 5, 2024

Type

docx

Pages

7

Uploaded by AmbassadorMonkeyPerson711 on coursehero.com

ITSS 4381.001 Spring 2024 – Assignment 3 Part 1 – Multiple Choice [40 Points] Each question is 5 points. Highlight your answer. 1. What happens when you add a key that already exists to a Python dictionary? A) A duplicate key-value pair is created, allowing multiple values for the same key. B) Python raises a KeyError, indicating that duplicate keys are not allowed. C) The value associated with the existing key is updated to the new value. D) The dictionary remains unchanged, ignoring the new key-value pair. 2. Which method allows you to safely remove a key from a dictionary and specify a default return value if the key does not exist, thereby avoiding a KeyError ? A) pop() B) del() C) popitem() D) remove() 3. What is a key characteristic that distinguishes tuples from lists in Python? A) Tuples can contain elements of different types, while lists cannot. B) Tuples are immutable, meaning once a tuple is created, its contents cannot be changed. C) Tuples are used exclusively for numerical data, while lists can contain any type of data. D) Tuples do not support indexing and slicing operations, unlike lists.
4. When using the open() function in Python to perform file operations, which of the following is the recommended way to handle exceptions, such as attempting to open a file that does not exist? A) Use a conditional statement to check if the file exists before attempting to open it. B) Utilize a try-except block, catching the FileNotFoundErro r exception to handle cases where the file does not exist. C) Ignore error handling; Python automatically creates the file if it does not exist, regardless of the operation. D) Call the os.exit() function if a FileNotFoundError is encountered to gracefully exit the program. 5. Which of the following best describes the role of the self parameter in the __init__ method of a Python class? A) It refers to the class itself and is used to define class variables. B) It is a placeholder for future arguments that might be passed to the method. C) It represents the instance of the class and is used to access attributes and methods. D) It specifies that the method should be automatically called when the class is first defined. 6. When creating a child class in Python, what is the correct way to call a method from the parent class within the child class ? A) Use the super() function followed by the method name to call the parent class's method. B) Use the method directly as if it were defined within the subclass itself. C) Prefix the method name with the parent class's name followed by a dot (.) operator. D) It's not possible to call a method from the parent class within the subclass; methods must be redefined.
7. In Python, how does method overriding work when dealing with inheritance? A) By declaring a method in the subclass with a different name but the same functionality as the one in the parent class. B) By defining a method in the subclass that has the same name as a method in the parent class, thus replacing the parent class's method when called on an instance of the subclass. C) By using the override keyword before a method in the subclass to explicitly indicate that it should replace a parent class method. D) Method overriding is not supported in Python; each subclass method must have a unique name. 8. Why is data normalization considered an important step in data preprocessing before applying machine learning algorithms? A) It converts all data to binary format, making it easier for algorithms to process the data. B) It reduces the data to a simpler form where all features contribute equally, preventing biases in the machine learning model. C) Normalization applies different scaling factors to each feature to enhance their original variance, making them more distinct. D) It ensures that all data points are limited to a specific range, such as 0 to 1, which helps in speeding up calculations and improving algorithm performance.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help