If you wish to make a shallow copy of a list, you can use the _______ method.

  • clone() Method
  • copy() Method
  • deepcopy() Method
  • slice() Method
To make a shallow copy of a list, you can use the 'copy()' method. It creates a new list containing references to the same objects as the original list.

If you want to make a variable defined in an outer function accessible to an inner function, you use the _______ keyword.

  • global
  • inner
  • outer
  • public
To make a variable defined in an outer function accessible to an inner function, you use the 'global' keyword. It indicates that the variable should be treated as a global variable.

Unlike lists, tuples are _______ in Python, meaning they cannot be modified after they are created.

  • Dynamic
  • Immutable
  • Mutable
  • Static
Tuples in Python are immutable, which means their elements cannot be changed or modified after the tuple is created.

You're working on a project where a derived class Laptop inherits from two base classes: Computer and PortableDevice. Both base classes have a method named power_on(). If you call power_on() from a Laptop object without any specifications, which method will be invoked?

  • An error will occur due to ambiguity in method names in the multiple inheritance scenario
  • The power_on() method of the Computer class will be invoked
  • The power_on() method of the Laptop class will be invoked
  • The power_on() method of the PortableDevice class will be invoked
In the case of multiple inheritance, if two base classes have a method with the same name, the method of the first base class listed in the inheritance declaration is invoked. In this scenario, calling power_on() from a Laptop object without specifications will invoke the power_on() method of the Computer class.

Who is the creator of Python?

  • Dennis Ritchie
  • Guido van Rossum
  • James Gosling
  • Larry Wall
Python was created by Guido van Rossum in the late 1980s and was first released in 1991.

_______ is an environment where you can write and execute Python commands one-by-one.

  • Compiler
  • Debugger
  • IDE
  • REPL
A REPL (Read-Eval-Print Loop) is an interactive environment where you can input and execute Python commands interactively.

If d is a dictionary, the method d.______() will return a list of all the values in the dictionary.

  • extract_values
  • get_values
  • list_values
  • values
The values() method in Python returns a view object that displays a list of all the values in the dictionary. You can convert this view to a list if needed.

Which of the following can be used to import only a specific function or class from a module?

  • from module import function
  • import function from module
  • import module
  • import module.function
You can use 'from module import function' to import only a specific function or class from a module in Python.

The true mechanism behind private attributes in Python is a feature called _______.

  • abstraction
  • data hiding
  • encapsulation
  • name mangling
Python uses a technique called "name mangling" to make attributes private by adding a prefix to their names.

The _______ operator returns True if the value on its left is less than the one on its right.

  • Greater than (>)
  • Greater than or equal to (>=)
  • Less than (<)
  • Less than or equal to (<=)
The 'Less than' operator returns True if the value on its left is less than the one on its right.