Which is faster, Python lists or Numpy arrays?
NumPy arrays
Why are NumPy arrays faster than Python lists?
NumPy arrays are implemented in C versus Python lists are implemented in Python. Because C is a compiled language, it is faster than Python, which is an interpreted language.
What are the differences between Python lists and tuples?
3 bullet points
[] whereas tuples are defined using parentheses ().What are the similarities between Python lists and tuples?
3 bullet points
What is a Python set?
Unordered collection of unique objects
What is the typical use case of Python sets?
Often used to store a collection of distinct objects and perform membership tests (i.e., to check if an object is in the set).
How are Python sets defined?
Curly braces, {}, and a comma-separated list of values.
What are the key properties of Python sets?
5 bullet points
What is the difference between Python split and join?
1 bullet point for each
Syntax: Python split
Include definition of any class objects and/or parameters
string.split(separator, maxsplit)
Syntax: Python join
Include definition of any class objects and/or parameters
separator.join(iterable)
What are the logical operators in Python? What are they used for?
and, or, notbool values.Logical operators in Python: and
Returns True if both operands are True; otherwise, False.
Logical operators in Python: or
Returns True if either of the operands are True; returns False if both operands are False.
Logical operators in Python: not
Returns True if the operand is False; returns False if the operand is True.
What are the top 6 functions used for Python strings?
len()strip()split()replace()upper()lower()Top 6 functions used for Python strings: len()
Returns the length of a string.
Top 6 functions used for Python strings: strip()
Removes leading and trailing whitespace from a string.
Top 6 functions used for Python strings: split()
Splits a string into a list of substrings based on a delimiter.
Top 6 functions used for Python strings: replace()
Replaces all occurrences of a specified string with another string.
Top 6 functions used for Python strings: upper()
Converts a string to uppercase.
Top 6 functions used for Python strings: lower()
Converts a string to lowercase.
What is the pass keyword in Python? What is it used for?
pass is a null statement that does nothing. It is often used as a placeholder where a statement is required syntactically, but no action needs to be taken.
What are some common use cases of the pass keyword in Python?
3 bullet points
pass to avoid syntax errors.if statement but don’t want to take any action in the if block, you can use pass.pass in loops when you don’t want to perform any action in a specific iteration.