Python Expert
Why do floating-point calculations seem inaccurate in Python?
Select the correct answer
Floating-point calculations seem inaccurate due to outdated Python versions.
Floating-point calculations seem inaccurate due to Python's internal bugs.
Floating-point calculations seem inaccurate due to incorrect math operations.
Floating-point calculations seem inaccurate due to binary representation limitations.
When Python program exits, why isn’t all the memory de-allocated?
Select the correct answer
Memory is de-allocated only in Python 3.
Not all memory is de-allocated because of cyclic references and the garbage collector's limitations.
All memory is de-allocated when a Python program exits.
Memory is not de-allocated due to Python's memory leak.
What is the difference between .py and .pyc files?
Select the correct answer
.py files are compiled files, while .pyc files are source files.
.py files contain the source code, while .pyc files contain the compiled bytecode.
.py files are for testing, while .pyc files are for production.
.py files are used for documentation, while .pyc files are used for execution.
How Python is interpreted?
Select the correct answer
Python is compiled, meaning code is converted to machine code.
Python is interpreted, meaning code is executed line by line.
Python is a hybrid language.
Python uses both compilation and interpretation simultaneously.
What is the process of compilation and linking in python?
Select the correct answer
Python code is not compiled, it is interpreted line by line.
Python code is linked directly to the OS.
Python code is compiled into machine code, which is then executed directly.
Python code is compiled into bytecode, which is then interpreted.
How is multithreading achieved in Python?
Select the correct answer
Multithreading in Python is achieved using the concurrent module.
Multithreading in Python is not supported.
Multithreading in Python is achieved using the threading module.
Multithreading in Python is achieved using the multiprocessing module.
What are function annotations in Python?
Select the correct answer
Function annotations in Python are used to create abstract methods.
Function annotations in Python are a way of associating metadata with function arguments and return values.
Function annotations in Python are a form of comments.
Function annotations in Python are used for exception handling.
What is monkey patching in Python?
Select the correct answer
Monkey patching is a method of testing code.
Monkey patching is creating multiple versions of a class.
Monkey patching is a way to document code.
Monkey patching is dynamically modifying a class or module at runtime.
What are generators in Python?
Select the correct answer
Generators in Python are a way to create dictionaries using yield statements.
Generators in Python are a way to create iterators using yield statements.
Generators in Python are functions that run indefinitely.
Generators in Python are used to create threads.
What are Eggs and Wheels in Python?
Select the correct answer
Eggs and Wheels are Python IDEs.
Eggs and Wheels are packaging formats used for distributing Python projects.
Eggs and Wheels are tools for Python testing.
Eggs and Wheels are Python debugging tools.
Describe memory management in Python.
Select the correct answer
Memory management in Python is only for built-in types.
Memory management in Python is handled manually by the programmer.
Memory management in Python is handled by the operating system.
Memory management in Python is handled by the Python memory manager and includes garbage collection.
Does Python support multiple inheritance?
Select the correct answer
Yes, but only with metaclasses.
No, Python does not support multiple inheritance.
Yes, Python supports multiple inheritance.
Yes, but only in Python 3.
What is inheritance in Python?
Select the correct answer
Inheritance in Python allows a class to inherit attributes and methods from another class.
Inheritance in Python is used to encapsulate methods.
Inheritance in Python prevents method overriding.
Inheritance in Python allows creating private methods.
What is polymorphism in Python?
Select the correct answer
Polymorphism in Python allows methods to do different things based on the object it is acting upon.
Polymorphism in Python allows objects to have multiple forms.
Polymorphism in Python refers to object inheritance.
Polymorphism in Python is achieved using the init method.
What is encapsulation in Python?
Select the correct answer
Encapsulation in Python is achieved by using private and protected members.
Encapsulation in Python is achieved by using public members only.
Encapsulation in Python is achieved by using only methods.
Encapsulation in Python is achieved by using decorators.
How is data abstraction achieved in Python?
Select the correct answer
Data abstraction in Python is achieved using global variables.
Data abstraction in Python is achieved using abstract classes and interfaces.
Data abstraction in Python is achieved using the init method.
Data abstraction in Python is achieved using the pass statement.
What are access specifiers in Python?
Select the correct answer
Python uses decorators for access specifiers.
Python uses self for access specifiers.
Python does not have access specifiers like private, public, and protected.
Python uses private, public, and protected keywords.
What is self in Python?
Select the correct answer
self in Python refers to the instance of the class.
self in Python is a keyword to access methods.
self in Python refers to the class itself.
self in Python is a global variable.
What is a zip function?
Select the correct answer
The zip function pairs elements from multiple iterables.
The zip function sorts elements from multiple iterables.
The zip function concatenates elements from multiple iterables.
The zip function filters elements from multiple iterables.
What is the difference between return and yield keywords?
Select the correct answer
The return keyword is used in loops, while yield is used in functions.
The return keyword pauses a function, while yield stops a function.
The return keyword sends a result back to the caller, while yield produces a generator.
The return keyword produces a generator, while yield sends a result back to the caller.
What’s the difference between a Set and a Frozenset?
Select the correct answer
A frozenset is immutable, while a set is mutable.
A frozenset is mutable, while a set is immutable.
A frozenset can be indexed, while a set cannot.
A frozenset is a subclass of set.
What is the difference between a Set and Dictionary?
Select the correct answer
A set is a collection of key-value pairs, while a dictionary is an unordered collection of unique items.
A set is immutable, while a dictionary is mutable.
A set is an unordered collection of unique items, while a dictionary is a collection of key-value pairs.
A set allows duplicate items, while a dictionary does not.
What are some of the differences between Lists and Tuples?
Select the correct answer
Lists are immutable, while tuples are mutable.
Lists are mutable, while tuples are immutable.
Lists can be nested, while tuples cannot.
Lists are for numeric data, while tuples are for text data.
What is a context manager in Python?
Select the correct answer
A context manager in Python is used for data storage.
A context manager in Python handles exceptions.
A context manager in Python allows for resource management.
A context manager in Python is used for string manipulation.
What is pickling and unpickling?
Select the correct answer
Pickling is the process of converting a Python object into a byte stream.
Pickling is the process of copying a Python object.
Pickling is the process of converting a Python object into a string.
Pickling is the process of encrypting a Python object.
Explain the logical operations in Python.
Select the correct answer
Logical operations in Python include and, or, and not.
Logical operations in Python include add, subtract, and multiply.
Logical operations in Python include if, elif, and else.
Logical operations in Python include equals, greater than, and less than.
What is PIP?
Select the correct answer
PIP is an IDE for Python.
PIP is a debugging tool in Python.
PIP is a Python interpreter.
PIP is a package management system used to install and manage Python packages.
What is main function in Python?
Select the correct answer
The main function in Python is executed when the script is run directly.
The main function in Python is used to declare global variables.
The main function in Python is called before every function.
The main function in Python is used to import modules.
What is the Python with statement used for?
Select the correct answer
The with statement in Python is used for resource management.
The with statement in Python is used for function definitions.
The with statement in Python is used for loops.
The with statement in Python is used for conditionals.
What are Iterators in Python?
Select the correct answer
Iterators in Python are objects that hold multiple items at once.
Iterators in Python are objects that implement the iterator protocol.
Iterators in Python are built-in functions for looping.
Iterators in Python are only used for dictionaries.
How can you insert an element into a specific position in a list?
Select the correct answer
You can insert an element into a specific position in a list using the update() method.
You can insert an element into a specific position in a list using the extend() method.
You can insert an element into a specific position in a list using the append() method.
You can insert an element into a specific position in a list using the insert() method.
Does removing the first item from a Python list take the same amount of time as removing the last item?
Select the correct answer
Removing the first item from a list takes longer than removing the last item.
Removing the first item from a list is not allowed in Python.
Removing the first item from a list takes the same time as removing the last item.
Removing the first item from a list is always faster than removing the last item.
What is enumerate() in Python?
Select the correct answer
enumerate() in Python adds a counter to an iterable and returns it.
enumerate() in Python concatenates iterables and returns it.
enumerate() in Python sorts an iterable and returns it.
enumerate() in Python filters an iterable and returns it.
What is a closure in Python?
Select the correct answer
A closure in Python is a nested function which has access to variables of the outer function.
A closure in Python is a function that only exists at runtime.
A closure in Python is a function without any arguments.
A closure in Python is a function that is called immediately after it is defined.
What is the difference between a module and a package in python?
Select the correct answer
A module is a built-in Python function, while a package is a user-defined function.
A module is used for object-oriented programming, while a package is for functional programming.
A module is a single file containing Python code, while a package is a collection of modules.
A module is a collection of packages, while a package is a single file containing Python code.
What is a namespace in Python?
Select the correct answer
A namespace in Python is a special type of module.
A namespace in Python is a variable type.
A namespace in Python is a function scope.
A namespace in Python is a container that holds a set of identifiers and their corresponding objects.
What's the difference between sort() and sorted() in Python?
Select the correct answer
Both sort() and sorted() return a new list.
sort() returns a new list, while sorted() modifies the list in-place.
sort() modifies the list in-place, while sorted() returns a new list.
Both sort() and sorted() modify the list in-place.
What is PYTHONPATH?
Select the correct answer
PYTHONPATH is an environment variable which you can set to add additional directories where Python will look for modules and packages.
PYTHONPATH is the default directory for Python scripts.
PYTHONPATH is a file path for the Python interpreter.
PYTHONPATH is a type of Python variable.
What is a lambda function in Python?
Select the correct answer
A lambda function is used to create classes.
A lambda function is a named function in Python.
A lambda function is a small anonymous function in Python.
A lambda function is used to declare variables.
What is the Global Interpreter Lock (GIL) in Python?
Select the correct answer
The Global Interpreter Lock (GIL) is a performance enhancement.
The Global Interpreter Lock (GIL) is used for thread optimization.
The Global Interpreter Lock (GIL) is a security feature in Python.
The Global Interpreter Lock (GIL) is a mutex that protects access to Python objects.
What is the difference between Arrays and lists in Python?
Select the correct answer
Arrays are fixed-size, while lists are dynamic-size.
Arrays can contain mixed types, while lists cannot.
Arrays are dynamic-size, while lists are fixed-size.
Arrays are a part of standard Python library, while lists are not.
Explain the difference between deep copy and shallow copy in Python.
Select the correct answer
A deep copy copies only immutable objects, while a shallow copy does not.
A deep copy copies all objects recursively, while a shallow copy does not.
A deep copy only copies primitive types, while a shallow copy does not.
A deep copy does not copy objects, while a shallow copy does.
Explain list comprehensions in Python.
Select the correct answer
List comprehensions are used to generate tuples.
List comprehensions are only used for filtering lists.
List comprehensions are used to define list classes.
List comprehensions provide a concise way to create lists.
What is the purpose of the __init__ method in a Python class?
Select the correct answer
The __init__ method is only used for inheritance.
The __init__ method is a destructor method.
The __init__ method is used to create a new class.
The __init__ method initializes an instance of a class.
Explain the use of the map() function in Python.
Select the correct answer
The map() function converts a list to a dictionary.
The map() function sorts the elements in an iterable.
The map() function applies a function to all items in an iterable.
The map() function filters elements from a list.
What is scope in Python?
Select the correct answer
Scope in Python is a method for optimizing memory.
Scope in Python is used to determine data types.
Scope in Python refers to the size of variables.
Scope in Python refers to the visibility of variables.
What are negative indexes in Python?
Select the correct answer
Negative indexes in Python allow counting from the end of a list.
Negative indexes in Python are only for string manipulation.
Negative indexes in Python are used for error handling.
Negative indexes in Python start the count from zero.
What is a docstring in Python, and why is it useful?
Select the correct answer
A docstring is a type of exception in Python.
A docstring is a comment used to document code in Python.
A docstring is a string literal used for documentation in Python.
A docstring is a variable name in Python.
Explain the pass statement in Python.
Select the correct answer
The pass statement pauses the execution of code.
The pass statement raises an exception.
The pass statement exits the current loop.
The pass statement is a no-op placeholder in Python.
How do you handle exceptions in Python?
Select the correct answer
Exceptions in Python are handled using error and catch blocks.
Exceptions in Python are handled using validate and except blocks.
Exceptions in Python are handled using try and catch blocks.
Exceptions in Python are handled using try and except blocks.
Is Python pass by reference or pass by value?
Select the correct answer
Python is pass by value.
Python is pass by object reference.
Python is pass by reference.
Python uses a mix of pass by reference and pass by value.
Explain mutable and immutable data types in Python?
Select the correct answer
Both mutable and immutable types cannot be changed after creation.
Mutable types cannot be changed after creation, while immutable types can.
Only strings in Python are immutable.
Mutable types can be changed after creation, while immutable types cannot.
What is PEP 8, and why is it important?
Select the correct answer
PEP 8 is a security standard in Python.
PEP 8 is a Python error prevention tool.
PEP 8 is a performance enhancement proposal.
PEP 8 is the style guide for writing Python code.
Is Python statically or dynamically typed?
Select the correct answer
Python is dynamically typed.
Python is weakly typed.
Python is statically typed.
Python uses type inference.
Is Python a compiled language or an interpreted language?
Select the correct answer
Python is an interpreted language.
Python is a compiled language.
Python is a scripting language only.
Python is a low-level programming language.