- Home
- Subjects
- Data Science
- Python
Python MCQs
595 multiple choice questions with answers in Data Science.
In the ever-changing landscape of programming languages, Python stands tall as a versatile force, reshaping how we engage with technology. Known for its simplicity and readability, Python has become the language of choice across diverse domains, including web development, data science, and artificial intelligence.Python's adaptability and extensive library ecosystem, featuring powerful frameworks like Django and Flask, empower developers to craft scalable solutions efficiently. Its intuitive syntax caters to both beginners and seasoned developers, facilitating quick learning.Python proficiency is a gateway to enhanced website performance and streamlined algorithmic implementations. As businesses prioritize technological excellence, Python emerges as a pivotal player, driving innovation and ensuring cutting-edge solutions. Embrace Python today to stay ahead in the ever-evolving digital landscape.
Showing 1–25 of 595
Which json.dumps argument sorts the keys alphabetically in Python?
- A ordered=True
- B sort=True
- C alpha=True
- D sort_keys=True Correct answer
MCQSEXAM
Read explanation
How can you get an environment variable without raising KeyError if missing in Python?
- A os.environ.get('NAME') Correct answer
- B os.environ['NAME']
- C os.getenvvar('NAME')
- D os.env('NAME')
MCQSEXAM
Read explanation
Which pandas function combines DataFrames like a SQL join in Python?
- A pd.merge() Correct answer
- B pd.join_all()
- C pd.link()
- D pd.attach()
MCQSEXAM
Read explanation
Which library is an ORM for working with databases in Python?
- A SQLAlchemy Correct answer
- B Seaborn
- C Pillow
- D NLTK
MCQSEXAM
Read explanation
What is the output of print(sum(i for i in [1, 2, 3])) in Python?
print(sum(i for i in [1, 2, 3]))
- A 6 Correct answer
- B Error
- C None
- D 3
MCQSEXAM
Read explanation
What is the output of print(float('inf')) in Python?
print(float('inf'))
- A Error
- B 0
- C None
- D inf Correct answer
MCQSEXAM
Read explanation
What is the output of print(dict(a=1, b=2)) in Python?
print(dict(a=1, b=2))
- A {'a': 1}
- B {'b': 2}
- C Error
- D {'a': 1, 'b': 2} Correct answer
MCQSEXAM
Read explanation
What is the default logging level of the root logger in Python?
- A DEBUG
- B WARNING Correct answer
- C INFO
- D ERROR
MCQSEXAM
Read explanation
What is the output of print(dict.fromkeys('ab', 0)) in Python?
print(dict.fromkeys('ab', 0))
- A {'a': None}
- B {'a': 0}
- C {'a': 0, 'b': 0} Correct answer
- D Error
MCQSEXAM
Read explanation
What does sys.exit() do in Python?
- A Closes the editor
- B Raises SystemExit to terminate the program Correct answer
- C Pauses the script
- D Restarts the interpreter
MCQSEXAM
Read explanation
What is the output of print('Value: %d' % 7) in Python?
print('Value: %d' % 7)
- A Value: 7 Correct answer
- B Value: %d
- C 7
- D Error
MCQSEXAM
Read explanation
In regular expressions, what does the dot . match by default in Python?
- A Only a period
- B Any character except a newline Correct answer
- C Any digit
- D Only letters
MCQSEXAM
Read explanation
Which method converts a datetime to a formatted string in Python?
- A strftime() Correct answer
- B strptime()
- C format_date()
- D tostring()
MCQSEXAM
Read explanation
What is the output of print(len({1: 'a', 2: 'b', 1.0: 'c', 3: 'd'})) in Python?
print(len({1: 'a', 2: 'b', 1.0: 'c', 3: 'd'}))
- A 3 Correct answer
- B 2
- C Error
- D 1
MCQSEXAM
Read explanation
What is the output of print('STRASSE'.casefold() == 'strasse') in Python?
print('STRASSE'.casefold() == 'strasse')
- A False
- B None
- C True Correct answer
- D Error
MCQSEXAM
Read explanation
What is the output of print(sum(1 for c in 'banana' if c == 'n')) in Python?
print(sum(1 for c in 'banana' if c == 'n'))
- A 3
- B 1
- C 2 Correct answer
- D Error
MCQSEXAM
Read explanation
Which pathlib method reads a whole text file in Python?
- A read_text() Correct answer
- B load()
- C get_text()
- D open_all()
MCQSEXAM
Read explanation
Which function creates a directory including missing parents in Python?
- A os.mkdir()
- B os.create()
- C os.newdir()
- D os.makedirs() Correct answer
MCQSEXAM
Read explanation
What error occurs when assigning to a property that has no setter in Python?
- A TypeError
- B ValueError
- C NameError
- D AttributeError Correct answer
MCQSEXAM
Read explanation
What does del x do in Python?
- A Always frees the object immediately
- B Removes the name x from the namespace Correct answer
- C Deletes the file x
- D Sets x to None
MCQSEXAM
Read explanation
What is the output of print({'a': 1, 'b': 2}.keys() - {'a': 0}.keys()) in Python?
print({'a': 1, 'b': 2}.keys() - {'a': 0}.keys())
- A {'b'} Correct answer
- B {'a'}
- C {'a', 'b'}
- D Error
MCQSEXAM
Read explanation
Which module copies and removes whole directory trees in Python?
- A os.path
- B shutil Correct answer
- C fileutil
- D dircopy
MCQSEXAM
Read explanation
What is the output of print(1_000_000) in Python?
print(1_000_000)
- A 1
- B Error
- C 1000000 Correct answer
- D 1_000_000
MCQSEXAM
Read explanation
What is the output of the following Python code snippet?
from datetime import date, timedelta
print(date(2024, 1, 1) + timedelta(days=10))
print(date(2024, 1, 1) + timedelta(days=10))
- A 2024-01-10
- B 2024-01-11 Correct answer
- C 2024-01-12
- D Error
MCQSEXAM
Read explanation
Teacher or blogger? Put this quiz on your website
Free Python MCQs quiz with answers for your school site, academy page or blog. Copy one line of code – works on WordPress and Blogger.
Get the quiz widgetAll 595 Python questions
Show the full list of questions in this topic
- What is the purpose of the __init__ method in Python?
- Which of the following statements is used for importing a module in Python?
- What is the primary purpose of the if __name__ == "__main__": statement in a Python script?
- In Python, which data structure is used to implement a queue?
- What does the len() function return in Python?
- How is exception handling implemented in Python?
- What is the purpose of the super() function in Python?
- Which of the following is a valid way to comment out multiple lines in Python?
- What does the __str__ method do in a Python class?
- Which module in Python provides support for regular expressions?
- Which of the following is the correct way to print "Hello, world!" in Python?
- What is the data type of the variable x in the this code? Python x = 10
- Which of the following statements is used to create a list in Python?
- What is the correct way to define a function in Python?
- What is the correct way to import a module named "math" in Python?
- What is the difference between a list and a tuple in Python?
- What is the purpose of the "if" statement in Python?
- What is the correct way to create a dictionary in Python?
- What does the 'print' function do?
- Which of the following is a correct variable assignment?
- What is the purpose of the 'input' function?
- Which data type is used to store a sequence of characters?
- What is the result of the expression 3 + 2 * 4?
- What does the 'len' function do?
- What is the purpose of the 'if' statement in Python?
- How do you open a file in Python?
- What is the purpose of the 'elif' statement?
- Which of the following is a valid way to define a function in Python?
- What is the purpose of the 'return' statement in a function?
- What is the purpose of the 'if' statement in Python program flow?
- Which of the following statements is used to execute a block of code repeatedly in Python?
- What is the key feature of the 'for' loop in Python?
- Which statement is used to terminate the current loop iteration in Python?
- What does the 'else' statement in a loop signify in Python?
- Which of the following statements is true about nested loops in Python?
- What is the purpose of the 'range' function in Python?
- Which of the following statements is used to handle exceptions in Python?
- What does the 'finally' block in a 'try-except' statement do?
- What is the purpose of the 'pass' statement in Python?
- Which statement is used to raise an exception in Python?
- What does the 'assert' statement in Python do?
- Which of the following is NOT a valid comparison operator in Python?
- What is the purpose of the 'break' statement in Python?
- What is the purpose of a virtual environment in Python?
- Which tool is commonly used for managing Python packages and dependencies?
- What is the purpose of requirements.txt file in Python projects?
- Which command is used to create a virtual environment in Python using virtualenv?
- What is the purpose of the 'conda' package manager?
- How do you activate a virtual environment in Python using virtualenv?
- What is the purpose of the '--user' flag when installing Python packages using pip?
- Which command is used to uninstall a Python package using pip?
- What is the purpose of the 'requirements.txt' file when collaborating on a Python project?
- What is the role of the Python interpreter?
- Which of the following commands is used to upgrade pip to the latest version?
- What is the purpose of the 'site-packages' directory in Python?
- Which command is used to create a virtual environment in Python using venv?
- What is the purpose of the '--no-site-packages' flag when creating a virtual environment in Python?
- Which of the following is NOT a valid way to activate a virtual environment in Python?
- What is the purpose of the 'pycache' directory in Python?
- Which command is used to list all installed Python packages?
- What is the purpose of the 'venv' module in Python?
- What is the purpose of the 'PYTHONPATH' environment variable in Python?
- What is the result of 5 // 2 in Python?
- Which of the following is an invalid integer in Python?
- What is the result of 3.5 + 2 in Python?
- What is the result of 'hello' + 'world' in Python?
- Which of the following is a valid float in Python?
- Which method is used to convert a string to lowercase in Python?
- What is the result of True and False in Python?
- How do you access the third element of a list named my_list in Python?
- Which of the following is a valid way to assign a boolean value in Python?
- Which method is used to add an element to the end of a list in Python?
- Which of the following is a characteristic of tuples in Python?
- Can you change the elements of a tuple after it has been created?
- Which of the following is a valid way to create an empty set in Python?
- What is the result of {1, 2, 3} | {3, 4, 5} in Python?
- How do you access the value associated with the key 'age' in a dictionary named person in Python?
- Which method is used to remove a key-value pair from a dictionary in Python?
- What will be the output of 7 % 3 in Python?
- Which of the following is not a valid way to represent an integer in Python?
- What will be the result of 4.2 * 3 in Python?
- Which of the following is a valid float representation in Python?
- What is the output of "python"[::-1] in Python?
- Which method is used to find the index of the first occurrence of a substring in a string?
- What is the result of not False in Python?
- Which of the following is not a valid boolean value in Python?
- Which of the following methods removes the last element from a list in Python?
- Which method is used to add an element to a set in Python?
- What will be the result of len({1, 2, 3, 4, 5}) in Python?
- Which of the following statements about tuples is true?
- What will be the result of len(['apple', 'banana', 'orange']) in Python?
- Which method is used to retrieve all keys from a dictionary in Python?
- What will be the output of len({'a': 1, 'b': 2, 'c': 3}) in Python?
- What is the result of round(3.75) in Python?
- Which of the following statements about floats in Python is true?
- What is the result of abs(-5) in Python?
- Which of the following statements about integers in Python is true?
- What is the result of "hello".upper() in Python?
- What is the result of True or False in Python?
- Which of the following statements about booleans in Python is true?
- Which of the following statements about strings in Python is true?
- Which of the following methods removes the first occurrence of a specific value from a list in Python?
- What will be the result of ['a', 'b', 'c'] * 2 in Python?
- Which of the following methods returns the number of occurrences of a specified value in a tuple?
- What will be the result of ('a', 'b') + ('c',) in Python?
- Which of the following methods removes all elements from a set in Python?
- What will be the result of {1, 2, 3} & {3, 4, 5} in Python?
- Which method is used to update a dictionary with elements from another dictionary or iterable?
- What will be the output of {'a': 1, 'b': 2}.values() in Python?
- What is the output of 2 ** 3 ** 2 in Python?
- Which of the following statements about integer division in Python 3.x is true?
- What will be the result of 0.1 + 0.2 == 0.3 in Python?
- Which of the following methods is used to retrieve the fractional and integer parts of a float separately?
- What is the result of "Python"[::-1] in Python?
- What will be the output of True + True in Python?
- Which of the following expressions returns False?
- What will be the result of [x for x in range(5)] in Python?
- Which method is used to reverse the elements of a list in place?
- Which method is used to remove leading and trailing whitespace from a string in Python?
- What will be the result of (1, 2) + (3, 4) in Python?
- Which of the following statements about tuples in Python is true?
- Which of the following methods is used to convert a string representation of a number to its corresponding integer value?
- What is the result of 2
- Which of the following methods is used to remove an element from a set without raising an error if the element is not present?
- What is the output of {'a': 1, 'b': 2}.values() in Python?
- What does the is operator check for when comparing two variables in Python?
- Which data type in Python is used to represent a sequence of Unicode characters?
- Which Python data type is immutable?
- Which Python keyword is used to define a function?
- What is the output of print(2 ** 3 ** 2) in Python?
- Which Python operator performs floor division?
- Which Python function returns the length of an object?
- Which Python module is used for regular expressions?
- Which Python function converts a string to lowercase?
- Which Python function removes whitespace from string ends?
- Which Python function returns the absolute value?
- Which Python function returns the largest item?
- Which Python function returns the smallest item?
- What does [x * x for x in range(4)] produce?
- def add(item, box=[]): box.append(item); return box. What does calling add(1) and then add(2) return the second time?
- Inside a function, what types do *args and **kwargs collect?
- In Python, a decorator is:
- What happens when a Python function contains the yield keyword?
- In standard CPython, what is the main effect of the Global Interpreter Lock (GIL)?
- What is the value of 'python'[1:4]?
- What does sorted(['kiwi', 'fig', 'banana'], key=len) return?
- What does enumerate(['a', 'b'], start=1) yield?
- What is the result of list(zip([1, 2, 3], ['a', 'b']))?
- Why use copy.deepcopy() instead of copy.copy() for a list of lists?
- What does the 'walrus operator' (:=), added in Python 3.8, do?
- According to PEP 8, how many spaces should be used for each indentation level?
- For nums = [10, 20, 30, 40], what is nums[-1]?
- What does {w: len(w) for w in ['hi', 'cat']} produce?
- What does any([0, '', None, 5]) return?
- What is the result of '-'.join(['a', 'b', 'c'])?
- Inside a nested function, which keyword lets you reassign a variable from the enclosing (outer) function?
- What does isinstance(True, int) return in Python?
- After a, *b = [1, 2, 3], what is the value of b?
- nums = [3, 1, 2]; result = nums.sort(). What is result?
- What does a method decorated with @classmethod receive as its first argument?
- In Python 3, what does map(str, [1, 2, 3]) return?
- What does the @dataclass decorator generate automatically for a class?
- With counts = defaultdict(int), what does counts['new'] return for a key never set before?
- What is the result of 'ab' * 3 in Python?
- What is the average time complexity of a dict lookup in Python?
- Which function checks whether an object is an instance of a class in Python?
- What is the output of print('1234'.isdigit()) in Python?
- Which of these can NOT be used as a dictionary key in Python?
- What does super() do in Python?
- What is the output of the following Python code snippet?
- What is the output of print({1, 2} ^ {2, 3}) in Python?
- What is the output of the following Python code snippet?
- What is the output of print([3, 1, 2].sort()) in Python?
- What is the output of print([x for x in range(5) if x % 2 == 0]) in Python?
- What is the output of print(list(range(5, 0, -1))) in Python?
- What is the output of print(all([1, 2, 3])) in Python?
- What is the output of the following Python code snippet?
- Which collections class provides default values for missing keys in Python?
- What does functools.lru_cache do in Python?
- What is the output of the following Python code snippet?
- What is the output of the following Python code snippet?
- What is a virtual environment in Python?
- What is the output of the following Python code snippet?
- What does MRO stand for in Python?
- What are type hints in Python?
- What error is raised when accessing a missing dict key with d[key] in Python?
- What is the output of the following Python code snippet?
- What is the difference between shallow copy and deep copy in Python?
- Which library is most commonly used for tabular data analysis in Python?
- What is the output of the following Python code snippet?
- What does the / in a function signature def f(a, /, b) mean in Python?
- Which keyword is used to define a function in Python?
- What does the break statement do in Python?
- Which command prints the Zen of Python?
- Which decorator defines a method that belongs to the class rather than an instance and receives cls in Python?
- Which special method enables the + operator for a class in Python?
- What is the output of print(sorted([2, 3, 1], reverse=True)) in Python?
- What is the recommended way to avoid the mutable default argument pitfall in Python?
- What is the result of 7 % 3 in Python?
- What is the output of print([1, 2, 3][::-1]) in Python?
- What does the continue statement do in Python?
- What is the purpose of __init__.py in a directory in Python?
- What is the output of print(len('Python')) in Python?
- Why is the with statement recommended when working with files in Python?
- What does the is operator check in Python?
- Which decorator defines a method that receives neither self nor cls in Python?
- What is the output of print(list({'a': 1, 'b': 2}.items())) in Python?
- What is the output of print(list(range(2, 8, 2))) in Python?
- What is the output of the following Python code snippet?
- What happens if you instantiate a class with an unimplemented abstractmethod in Python?
- How does CPython primarily manage memory?
- What is the difference between remove() and discard() on a set in Python?
- What is the time complexity of accessing a list element by index in Python?
- What is the output of print({1, 2}.issubset({1, 2, 3})) in Python?
- What exception is raised when calling a method on None, e.g. None.upper() in Python?
- What is the output of print(int('1010', 2)) in Python?
- What algorithm does Python use to compute MRO?
- What is encapsulation in Python?
- What is the default recursion limit in CPython?
- What is the difference between sort() and sorted() in Python?
- What is a context manager in Python?
- What does the strip() method do in Python?
- What exception is raised when you access a list index that does not exist in Python?
- Which of these is NOT a Python keyword?
- What is the output of the following Python code snippet?
- Which block always runs, whether or not an exception occurred in Python?
- What is the name of the constructor-like method in a Python class?
- What is the difference between an iterable and an iterator in Python?
- Which special method makes two objects comparable with == in Python?
- Which module provides the @contextmanager decorator in Python?
- What is the output of the following Python code snippet?
- What is the output of the following Python code snippet?
- How do you write a multi-line string in Python?
- What is the output of the following Python code snippet?
- What does a single leading underscore (_x) in a name signify in Python?
- What is the output of print(any([])) in Python?
- What is the output of the following Python code snippet?
- Which tool is the standard package installer for Python?
- Which data structure in Python is best for fast membership checks?
- What is the output of print('Python'[-1]) in Python?
- What is the difference between import x and from x import y in Python?
- What is the output of the following Python code snippet?
- Which module provides mathematical functions such as sqrt() and sin() in Python?
- What does the nonlocal keyword do in Python?
- What is the output of print([5, 6, 7].index(7)) in Python?
- Which special method allows an object to be called like a function in Python?
- What is the output of the following Python code snippet?
- What is the output of the following Python code snippet?
- What does enumerate(items, start=1) do in Python?
- What is the output of the following Python code snippet?
- What is the output of the following Python code snippet?
- What is the output of print(0.1 + 0.2 == 0.3) in Python?
- What is the output of the following Python code snippet?
- What does sys.getrefcount(obj) return in Python?
- How do you define a custom exception in Python?
- What is the output of the following Python code snippet?
- What is the time complexity of the in operator on a list in Python?
- When does the else block of a try statement run in Python?
- What is the output of print('Python'[1:4]) in Python?
- What is the output of print('python'.find('z')) in Python?
- What is the output of print(isinstance(int, object)) in Python?
- What is the output of the following Python code snippet?
- Which command creates a virtual environment in Python?
- What is the output of print(1 in {'a': 1}) in Python?
- What does append() return in Python?
- What does self refer to in an instance method in Python?
- What does setdefault(key, default) do in Python?
- What does the assert statement do in Python?
- What is the purpose of the if __name__ == '__main__': block in Python?
- What is the default indentation recommended by PEP 8 in Python?
- What exception is raised by int('abc') in Python?
- What is the practical effect of the GIL on CPU-bound threads in CPython?
- Which module is used to work with JSON in Python?
- What is the output of print(sorted(['banana', 'pie', 'apple'], key=len)) in Python?
- What is the output of the following Python code snippet?
- What is the output of print('Python'.replace('P', 'J')) in Python?
- What is the output of print('Python'.startswith('Py')) in Python?
- What is the output of print(list(filter(lambda x: x % 2 == 0, [1, 2, 3, 4]))) in Python?
- What does json.loads() do in Python?
- What is the main advantage of generators over lists in Python?
- What is the output of the following Python code snippet?
- What does LEGB stand for in Python scope resolution?
- What is the output of print(any([0, 0, 1])) in Python?
- Which module is used to create abstract base classes in Python?
- What is the output of the following Python code snippet?
- What is the output of print('th' in 'Python') in Python?
- What is the output of the following Python code snippet?
- Which keyword turns a function into a generator in Python?
- What is the output of the following Python code snippet?
- What is the output of print('' or 'hello') in Python?
- What is PEP 8 in Python?
- What is the output of print('Python'[::-1]) in Python?
- What is the output of print(sorted([3, 1, 2], key=lambda x: x)) in Python?
- What is the output of the following Python code snippet?
- How can you see a class's MRO in Python?
- What is the output of print(5 and 0) in Python?
- Which module is best suited for I/O-bound concurrency with async/await in Python?
- What does a bare * in def f(a, *, b) mean in Python?
- What is the output of the following Python code snippet?
- Which function checks whether a class inherits from another in Python?
- Which module reads and writes CSV files in Python?
- Which module provides deepcopy() for copying nested objects in Python?
- What is the output of print([1, 2, 2, 3].count(2)) in Python?
- What is the output of print([1, 2] == [1, 2]) in Python?
- What does namedtuple from collections provide in Python?
- What exception does next() raise when an iterator is exhausted in Python?
- What is the output of print(callable(len)) in Python?
- What happens when you open an existing file with mode 'w' in Python?
- Which function returns the data type of an object in Python?
- What is the output of the following Python code snippet?
- What is the output of print(hex(255)) in Python?
- What is the output of print(bool('0')) in Python?
- What is the output of the following Python code snippet?
- Which collection can be used as a dictionary key in Python?
- What does a bare except: clause catch in Python?
- What is polymorphism in Python?
- What is the output of the following Python code snippet?
- What does a docstring do in Python?
- What does asyncio.run() do in Python?
- What is the output of the following Python code snippet?
- What is the output of print(all([])) in Python?
- What is the output of print([10, 20, 30, 40][1:3]) in Python?
- Who created the Python programming language?
- What does the Zen of Python state is better than complex?
- Which method splits a string into lines in Python?
- Which statement about tuples and lists is correct in Python?
- What is the difference between __str__ and __repr__ in Python?
- What does the @dataclass decorator generate automatically in Python?
- What exception is raised when the recursion limit is exceeded in Python?
- Which Python version introduced f-strings?
- What is the output of print([1, 2] * 2) in Python?
- What is the output of the following Python code snippet?
- What is the output of print(f'{3.14159:.2f}') in Python?
- What is the output of the following Python code snippet?
- Which mode opens a file for appending text in Python?
- What is the output of print('42'.zfill(5)) in Python?
- What is the maximum value of an int in Python 3?
- What is the output of the following Python code snippet?
- Which built-in returns a function's documentation string in Python?
- What does the os module provide in Python?
- Which module serialises Python objects to a binary format?
- Which module in the standard library is used for regular expressions in Python?
- What is the output of print(True + True) in Python?
- What is the output of the following Python code snippet?
- What is a frozenset in Python?
- Which special method makes len(obj) work in Python?
- What is the output of print(list(map(lambda x: x * x, [1, 2, 3]))) in Python?
- How does Python define a block of code such as a loop body or function body?
- What does functools.partial do in Python?
- What is the output of the following Python code snippet?
- What is the output of the following Python code snippet?
- What is the output of print(0 or 0) in Python?
- What is the output of the following Python code snippet?
- What is a closure in Python?
- How do you remove duplicates from a list while ignoring order in Python?
- Which special method makes an object usable in a for loop in Python?
- What does json.dumps() return in Python?
- What does the id() function return in Python?
- What does __slots__ do in a class in Python?
- What is the output of the following Python code snippet?
- What does raise ... from e do in Python?
- What is the output of print(round(2.5)) in Python?
- Which functools helper preserves a wrapped function's name and docstring in a decorator in Python?
- What is the output of print({1, 2} - {2, 3}) in Python?
- Which of the following is an immutable data type in Python?
- What does random.randint(1, 6) return in Python?
- Python is best described as which type of language?
- What is the output of print(bin(5)) in Python?
- Which approach gives true CPU parallelism in standard CPython?
- Which is the base class of all built-in exceptions in Python?
- What is the output of print(list(zip([1, 2], ['a']))) in Python?
- What is the output of print('ab' * 2) in Python?
- What does the @property decorator do in Python?
- What is the output of print({1, 2} | {2, 3}) in Python?
- What is the output of print('a' in {'a': 1}) in Python?
- Which library is widely used for numerical computing with arrays in Python?
- What is the output of the following Python code snippet?
- What does GIL stand for in Python?
- What is multiple inheritance in Python?
- What is the output of the following Python code snippet?
- What is the result of 7 // 2 in Python?
- Since which Python version are dictionaries guaranteed to preserve insertion order?
- What does the ord() function return in Python?
- What does a double leading underscore (__x) in a class attribute trigger in Python?
- What is the output of print({'a': 1, 'b': 2} | {'b': 3}) in Python?
- What is the output of print(round(3.14159, 2)) in Python?
- Which module provides exact decimal arithmetic in Python?
- What is the output of print(sum([1, 2, 3])) in Python?
- What is the output of print('5' + '5') in Python?
- What is a decorator in Python?
- What is the output of print((lambda a, b: a * b)(2, 3)) in Python?
- What is the output of the following Python code snippet?
- What does the await keyword do in Python?
- Which method reads the entire content of a file as a string in Python?
- What is the data type of the value True in Python?
- What is the output of the following Python code snippet?
- What is the output of print((1, 2, 1, 3, 1).count(1)) in Python?
- What is the output of the following Python code snippet?
- What does del a[0] do on a list a in Python?
- What is the output of the following Python code snippet?
- Which module offers object-oriented filesystem paths in Python?
- What does sys.argv contain in Python?
- What is the output of the following Python code snippet?
- What does os.environ provide in Python?
- What is the output of the following Python code snippet?
- What is the output of print(1
- Which approach is generally faster for concatenating many strings in a loop in Python?
- What is a memory leak candidate in Python even with garbage collection?
- Which module computes hashes like SHA-256 in Python?
- What is the output of the following Python code snippet?
- Which tool is commonly used to manage multiple dependency sets and lock files in modern Python projects?
- What does python -c 'print(1+1)' do?
- What is the output of the following Python code snippet?
- What does mypy do in Python?
- Which module offers thread-based concurrency in Python?
- What is the output of print(7.5 // 2) in Python?
- What does df.dropna() do in Python?
- What is the output of print('ab'.removesuffix('b')) in Python?
- Which module creates temporary files and directories in Python?
- What is the output of print(sorted({'a': 3, 'b': 1, 'c': 2}.values())) in Python?
- What is the output of print([1, 2, 3][5:]) in Python?
- What is the output of the following Python code snippet?
- What is the output of the following Python code snippet?
- What does the -m flag do in python -m pip install requests?
- Which threading primitive prevents simultaneous access to shared data in Python?
- What does timeit do in Python?
- What does it mean that Python's sort is stable?
- Which DataFrame method shows the first five rows by default in Python?
- What is the output of the following Python code snippet?
- Why are Python strings immutable?
- What does the underscore _ hold in the interactive interpreter in Python?
- Why are NumPy arrays faster than Python lists for numeric work?
- What is the output of print({1, True, 2}) in Python?
- Which pytest feature lets you reuse setup code across tests in Python?
- What is the output of print(b'hi'.decode()) in Python?
- Which argument avoids blank lines when writing CSV files on Windows in Python?
- What is the output of print({1, 2}
- Which Python version introduced the walrus operator :=?
- Why should SQL queries use parameter placeholders instead of string formatting in Python?
- What is the output of print(sum(c in 'aeiou' for c in 'education')) in Python?
- Which module should be used to handle time zones in modern Python (3.9+)?
- What does the global statement affect in Python?
- What is the output of print({1, 2}.isdisjoint({3, 4})) in Python?
- Which tool lints Python code for errors and style issues?
- What is the output of the following Python code snippet?
- What is the output of print(len({'a': 1, 'b': 2, 'c': 3})) in Python?
- What does sys.path contain in Python?
- What does the send() method of a generator do in Python?
- What is the output of the following Python code snippet?
- What is the result of np.array([1, 2, 3]) * 2 in Python?
- What module can profile where a Python program spends time?
- What happens to hashing when you define __eq__ without __hash__ in Python?
- What does generator.close() do in Python?
- What is the output of the following Python code snippet?
- What is bytecode in Python?
- What is the output of print((1, 2, 3) < (1, 3)) in Python?
- What Python value does JSON null become after json.loads?
- What is the output of the following Python code snippet?
- Which module provides the fast heap-based priority queue in Python?
- Which module is used for secure random tokens and passwords in Python?
- What is the output of print(f'{0.5:.2%}') in Python?
- What is the output of print('abc'.isalpha()) in Python?
- What is the output of the following Python code snippet?
- What is the output of print(5 ^ 6) in Python?
- What is the output of print(list(reversed([3, 2, 1]))) in Python?
- What is the correct order of logging levels from lowest to highest severity in Python?
- What does the pip freeze command output in Python?
- What is the output of the following Python code snippet?
- What is the output of print('Programming'[::-1]) in Python?
- What is the output of print('xxhello'.lstrip('x')) in Python?
- Which module offers a thread-safe FIFO queue in Python?
- What is the difference between loc and iloc in pandas in Python?
- What is the output of the following Python code snippet?
- What is the output of print(10 ** 100 < float('inf')) in Python?
- What is the output of print('abc'[::2]) in Python?
- What is a common use of a classmethod in Python?
- Which is called first when creating an instance: __new__ or __init__ in Python?
- What is the output of the following Python code snippet?
- What does deque(maxlen=3) do when a fourth item is appended in Python?
- What does python -m http.server do?
- What is the output of print(list(map(str.lower, ['A', 'B', 'C']))) in Python?
- What does the dir() function do with no arguments in Python?
- Which method counts missing values per column in Python?
- Which pandas function reads a CSV file into a DataFrame in Python?
- What is the output of the following Python code snippet?
- Which class in the csv module reads rows as dictionaries in Python?
- What is the output of the following Python code snippet?
- What is the output of the following Python code snippet?
- What is the output of print(bool([])) in Python?
- What does re.compile() provide in Python?
- What is a weak reference in Python?
- What is the output of the following Python code snippet?
- What does yield from do in Python?
- What is the output of the following Python code snippet?
- What is broadcasting in NumPy in Python?
- What does asyncio.gather() do in Python?
- What does @dataclass(frozen=True) do in Python?
- Which pandas method groups data for aggregation in Python?
- What is the output of print('{1} and {0}'.format(20, 10)) in Python?
- What is the output of print(float('nan') == float('nan')) in Python?
- Which module provides type hint helpers such as List, Optional and Union in Python?
- What is the output of print(sum(x for x in range(5))) in Python?
- What is the default encoding for str.encode() in Python 3?
- What is the end of life status of Python 2?
- What is the output of the following Python code snippet?
- What is the output of print(sorted('listen') == sorted('silent')) in Python?
- What is the output of print('hi'.encode()) in Python?
- What is the Singleton pattern in Python?
- What is the output of the following Python code snippet?
- What is the output of the following Python code snippet?
- What is the output of print({'a'}
- What is pyproject.toml used for in Python?
- Which sorting algorithm does Python's sorted() use?
- What is the output of the following Python code snippet?
- What does PEP stand for in Python?
- What does np.arange(0, 10, 2) produce in Python?
- Which collections type provides O(1) appends and pops from both ends in Python?
- What does int | None mean in a type hint (Python 3.10+)?
- What is the output of the following Python code snippet?
- What is duck typing in Python?
- What does re.match() check in Python?
- Which Python version introduced the match statement?
- What is the output of the following Python code snippet?
- Which module performs binary search on a sorted list in Python?
- What is the right way to pause inside a coroutine without blocking the event loop in Python?
- What is the output of the following Python code snippet?
- What is the output of print(int(False)) in Python?
- What does the doctest module do in Python?
- Which DataFrame method gives summary statistics of numeric columns in Python?
- Which pandas structure is a one-dimensional labelled array in Python?
- Which module encodes data to Base64 in Python?
- What is the naming convention for unittest test methods in Python?
- What is the output of the following Python code snippet?
- What is the output of the following Python code snippet?
- Which library provides machine learning algorithms such as classification and regression in Python?
- What is the output of print([3, 1].sort() == [1, 3]) in Python?
- What is a metaclass in Python?
- What is the output of the following Python code snippet?
- What is composition in OOP in Python?
- What is the output of the following Python code snippet?
- Which function is recommended for measuring elapsed time precisely in Python?
- Which module runs external commands and captures their output in Python?
- What is the output of the following Python code snippet?
- What is a race condition in Python?
- What is the difference between bytes and bytearray in Python?
- What is the output of the following Python code snippet?
- Which built-in module lets you work with SQLite databases in Python?
- Which class provides a high-level interface for thread and process pools in Python?
- Which Python implementation uses a just-in-time (JIT) compiler for speed?
- What is the output of the following Python code snippet?
- What is the output of the following Python code snippet?
- What is the output of print(len(max(['a', 'abc', 'ab'], key=len))) in Python?
- What is the output of print(dict.fromkeys(['a', 'b'])) in Python?
- What is the output of the following Python code snippet?
- What does time.time() return in Python?
- What is the output of print([x for x in [1, 2, 3] if x > 1]) in Python?
- What does json.dumps(obj, indent=2) do in Python?
- What does Optional[int] mean in a type hint in Python?
- What is the output of print({1: 'a', True: 'b'}) in Python?
- What is the time complexity of Python's built-in sort?
- What is the output of print(6 & 7) in Python?
- What does the gc module control in Python?
- What is the output of print(pow(6, 2, 10)) in Python?
- Where are compiled .pyc files stored in Python?
- What is the diamond problem in multiple inheritance in Python?
- Which tool formats Python code automatically with an uncompromising style?
- What is the output of print('Z' < 'a') in Python?
- What is the output of the following Python code snippet?
- What is string interning in Python?
- What is the output of the following Python code snippet?
- What is the output of the following Python code snippet?
- What is the output of print(1_000_000) in Python?
- Which module copies and removes whole directory trees in Python?
- What is the output of print({'a': 1, 'b': 2}.keys() - {'a': 0}.keys()) in Python?
- What does del x do in Python?
- What error occurs when assigning to a property that has no setter in Python?
- Which function creates a directory including missing parents in Python?
- Which pathlib method reads a whole text file in Python?
- What is the output of print(sum(1 for c in 'banana' if c == 'n')) in Python?
- What is the output of print('STRASSE'.casefold() == 'strasse') in Python?
- What is the output of print(len({1: 'a', 2: 'b', 1.0: 'c', 3: 'd'})) in Python?
- Which method converts a datetime to a formatted string in Python?
- In regular expressions, what does the dot . match by default in Python?
- What is the output of print('Value: %d' % 7) in Python?
- What does sys.exit() do in Python?
- What is the output of print(dict.fromkeys('ab', 0)) in Python?
- What is the default logging level of the root logger in Python?
- What is the output of print(dict(a=1, b=2)) in Python?
- What is the output of print(float('inf')) in Python?
- What is the output of print(sum(i for i in [1, 2, 3])) in Python?
- Which library is an ORM for working with databases in Python?
- Which pandas function combines DataFrames like a SQL join in Python?
- How can you get an environment variable without raising KeyError if missing in Python?
- Which json.dumps argument sorts the keys alphabetically in Python?
- What is the difference between concurrency and parallelism in Python?