Python lists | 4/100 Days of Python Algo trading

Python lists

Congratulations on reaching this stage!

If you’re here, it means you’re truly dedicated to mastering Python. Directly below, you’ll find a quiz designed to help you reinforce what you’ve just learned. This isn’t just about recalling facts; it’s about deeply understanding the concepts. Take a moment to answer the questions and see how well you can apply the knowledge from the video. You’re doing great—every question you tackle brings you one step closer to becoming a Python expert!

Day 4: Python Lists

1. Python lists and arrays are similar but have a key difference. What is it?
2. How are lists represented in Python's memory?
3. Which of the following are characteristics of Python lists? (Choose all that apply)
4. What's the output of this code?
Python
my_list = [1, 2, "hello"]
print(my_list[
1])
5. What's the difference between the append() and extend() methods for lists?
6. What does my_list.insert(2, "new") do?
7. How can you delete the element at index 1 from a list named numbers?
8. What is the result of [1, 2, 3] * 2?
9. How do you check if the value 5 is present in a list named my_list?
10. What does the len() function do when used with a list?
11. What does the my_list.sort() method do?
12. How would you find the minimum value in a list called numbers?
13. What does the list.reverse() method do?
14. What's a concise way to create a list of squares of numbers 1 to 10?
15. How would you iterate through a list named colors and print both the index and value of each element?
16. Consider these lists: names = ["Alice", "Bob"] and ages = [25, 30]. What's the output of list(zip(names, ages))?
17. List as heterogeneous containers: Which code demonstrates that Python lists can store different data types?
18. What is a potential disadvantage of using Python lists?
19. For scenarios focusing heavily on search operations, what might be a better alternative to a Python list?
20. In which situation might using a NumPy array be more advantageous than a Python list?