Prompt:
Design a Python programming question based on the content of lists, including list creation, list indexing and slicing, list methods (sorting, reverse, etc.) and nested lists.
Result:
Sure, here's a sample question:
Question: You have a list of integers named 'numbers' containing numbers from 1 to 20. Write a Python code to create two new lists - 'even_numbers' containing all even numbers from 'numbers' and 'odd_numbers' containing all odd numbers from 'numbers'. Sort both lists in ascending order using the built-in sort() method. Finally, use list slicing to extract the first five elements of each sorted list and store them in separate variables.
Example input: numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
Example output: even_first_five = [2, 4, 6, 8, 10] odd_first_five = [1, 3, 5, 7, 9]