Which memory management technique does Python primarily utilize?

  • Garbage Collection (GC)
  • Manual Memory Management (malloc/free)
  • Reference Counting
  • Stack Allocation
Python primarily utilizes Garbage Collection (GC) for memory management. It automatically deallocates memory occupied by objects that are no longer in use, making memory management more convenient and reducing the risk of memory leaks.

Which Python module provides functionality to read and write data in CSV format?

  • csv
  • dataio
  • table
  • textfile
The csv module in Python provides functionality for reading and writing data in CSV (Comma-Separated Values) format, making it a popular choice for working with spreadsheet-like data.

The file method _______ is used to obtain the current position of the file read/write pointer.

  • current_position()
  • file_position()
  • get_position()
  • tell()
The tell() method in Python's file handling is used to obtain the current position of the file read/write pointer. It returns an integer representing the current position in bytes. This is crucial when you want to navigate through a file or keep track of where you are when reading or writing data.

When iterating over a dictionary's items, each item is presented as a _______.

  • Key
  • Key-Value Pair
  • Tuple
  • Value
When iterating over a dictionary, each item is presented as a key-value pair (a tuple), where the key represents the dictionary's key, and the value represents the corresponding value associated with that key.

When using the setdefault method on a dictionary, what happens if the provided key already exists in the dictionary?

  • A new key-value pair is added with the default value
  • An error is raised
  • The existing key-value pair is overwritten with the default value
  • The existing value is returned
When setdefault is called with an existing key, it doesn't modify the existing value but returns it. If the key doesn't exist, it adds the key with the provided default value.

Which of the following set methods does not modify the set but returns a new set?

  • difference()
  • intersection()
  • issubset()
  • union()
The union() method returns a new set that contains all the elements from both sets without modifying the original sets.

When a package is imported, Python searches for _______ to determine the package's initialization.

  • init.py
  • main.py
  • package.py
  • startup.py
When a package is imported, Python searches for the __init__.py file to determine the package's initialization. This file is executed when the package is imported.

Python was named after the British comedy show "Monty Python's _______ Circus".

  • Comedy
  • Flying
  • Hilarious
  • Silly
Python was named after the British comedy show "Monty Python's Silly Circus." The creators found inspiration in the show's humor and absurdity.

In which block do you write the code that might raise an exception?

  • except
  • finally
  • raise
  • try
You write the code that might raise an exception in the try block in Python. The try block contains the code that you want to monitor for exceptions. If an exception occurs, it is caught by the except block.

In Python, every function returns a value. If no return statement is present, it returns _______ by default.

  • 0
  • FALSE
  • None
  • TRUE
In Python, if no return statement is present in a function, it returns 'None' by default. 'None' is a special value representing the absence of a value.