Latest Version Graded A+
What is the difference between `==` and `is` in Python?
✔✔ `==` checks if the values of two objects are equal, while `is` checks if two objects are the
same in memory.
What does the `type()` function do in Python?
✔✔ The `type()` function returns the type of an object.
How can you generate a random number in Python?
✔✔ Use the `random.randint(a, b)` function to generate a random integer between `a` and `b`
inclusive.
What is the purpose of the `break` statement?
✔✔ The `break` statement exits the nearest enclosing loop immediately.
How can you get the length of a string in Python?
✔✔ Use the `len()` function, like `len('hello')`.
1
, What is the purpose of the `continue` statement?
✔✔ The `continue` statement skips the current iteration of a loop and moves to the next iteration.
How do you create a dictionary in Python?
✔✔ Use curly braces to define a dictionary, like `my_dict = {'key1': 'value1', 'key2': 'value2'}`.
What is a slice in Python?
✔✔ A slice is used to access a range of elements from a sequence, such as a list or string, using
the colon (`:`) operator.
How do you reverse a string in Python?
✔✔ Use slicing with `[::-1]`, like `'hello'[::-1]` to get `'olleh'`.
What is the difference between `del` and `remove()` in Python?
✔✔ `del` removes an item by index or deletes an entire variable, while `remove()` removes an
item by value.
2