Which of the following is false?(1 point)ResponsesA stack uses a last in, first out (LIFO) approachA stack uses a last in, first out (LIFO) approachA heap must be manually managed.A heap must be manually managed.A stack automatically deallocates space when variables are no longer needed.A stack automatically deallocates space when variables are no longer needed.A heap is generally faster than a stack.A heap is generally faster than a stack.Question 2True or False? In Python, a file is always automatically closed for you after you are done reading it or writing to it.(1 point)ResponsesTrueTrueFalseFalseQuestion 3What type of file is best for storing discrete items that are stored in rows?(1 point)ResponsesCSVCSVtexttextDocumentDocumentPythonPythonQuestion 4Which of the following is the correct way to instantiate an object belonging to the user-defined class Dog that has attributes of name and breed? (1 point)Responsespet = new Dog("Fido", "puppy", "Dalmatian")pet = new Dog("Fido", "puppy", "Dalmatian")dog = Dog(self, "Buddy", "Boxer")dog = Dog(self, "Buddy", "Boxer")dog = new Dog(self, "Oscar", "Lab")dog = new Dog(self, "Oscar", "Lab")pet = Dog("Spot", "Dalmatian")pet = Dog("Spot", "Dalmatian")

1 answer

Let's go through each question.

Question 1: Which of the following is false?

  1. A stack uses a last in, first out (LIFO) approach (True)
  2. A heap must be manually managed. (True)
  3. A stack automatically deallocates space when variables are no longer needed. (True)
  4. A heap is generally faster than a stack. (False)

Answer: A heap is generally faster than a stack. (This statement is false; generally, the stack is faster than the heap due to how they manage memory.)


Question 2: True or False? In Python, a file is always automatically closed for you after you are done reading it or writing to it. The answer is False. In Python, files are not automatically closed; you need to close them explicitly or use a with statement to ensure they are closed automatically at the end of the block.

Answer: False


Question 3: What type of file is best for storing discrete items that are stored in rows? The most suitable option for storing discrete items in rows is a CSV (Comma-Separated Values) file, as it is designed for tabular data where each row is a separate entry.

Answer: CSV


Question 4: Which of the following is the correct way to instantiate an object belonging to the user-defined class Dog that has attributes of name and breed? The correct way to instantiate an object in Python is to directly call the class name followed by the arguments needed in parentheses. The option pet = Dog("Spot", "Dalmatian") follows this syntax correctly.

Answer: pet = Dog("Spot", "Dalmatian")


Summary of Answers:

  1. A heap is generally faster than a stack. (False)
  2. False
  3. CSV
  4. pet = Dog("Spot", "Dalmatian")