Pass
What is the result of `2 ** 3` in Python?
✔✔The result of `2 ** 3` is `8`, as `**` is the exponentiation operator.
How can you check if a number is even in Python?
✔✔You can check if a number is even by using the modulus operator: `if num % 2 == 0:`.
What does the `sorted()` function do in Python?
✔✔The `sorted()` function returns a new list with the items sorted in ascending order.
How can you swap two variables in Python?
✔✔You can swap two variables in Python with the syntax: `a, b = b, a`.
What is a lambda function in Python?
✔✔A lambda function is an anonymous function defined using the `lambda` keyword, e.g.,
`lambda x: x + 2`.
1
, What happens when you divide by zero in Python?
✔✔Dividing by zero in Python raises a `ZeroDivisionError`.
What is the purpose of `pass` in Python?
✔✔The `pass` statement is used as a placeholder where a statement is syntactically required, but
you don't want to write any code.
How do you handle exceptions in Python?
✔✔Exceptions are handled using a `try` and `except` block.
What does `zip()` do in Python?
✔✔The `zip()` function combines two or more iterables element-wise into tuples, returning an
iterator.
How can you remove an item from a list by value in Python?
✔✔You can remove an item from a list by value using the `remove()` method, e.g.,
`my_list.remove(2)`.
2