Version Graded A+
What is the difference between a list and a set in Python?
✔✔ A list is ordered and allows duplicates, while a set is unordered and only contains unique
elements.
How do you convert a string to a float in Python?
✔✔ Use the `float()` function, like `float('3.14')`.
What is a slice in Python?
✔✔ A slice is a subset of a list, string, or tuple, defined by a range of indices.
How do you join a list of strings into a single string in Python?
✔✔ Use the `join()` method, like `''.join(my_list)`.
What is the purpose of the `continue` statement in a loop?
✔✔ The `continue` statement skips the current iteration and moves to the next iteration of the
loop.
1
, How do you create a dictionary with key-value pairs in Python?
✔✔ Use curly braces with key-value pairs, like `{'key1': 'value1', 'key2': 'value2'}`.
What is the difference between `del` and `remove()` in Python?
✔✔ `del` removes an item by index or deletes an entire object, while `remove()` deletes an item
by its value.
How do you get the current date and time in Python?
✔✔ Use the `datetime.now()` function from the `datetime` module.
What is the purpose of the `global` keyword in Python?
✔✔ The `global` keyword allows you to modify a variable outside the current function's scope.
How do you create a set in Python?
✔✔ Use curly braces or the `set()` constructor, like `set([1, 2, 3])`.
How do you handle multiple exceptions in Python?
2