Answered step by step
Verified Expert Solution
Question
1 Approved Answer
QUESTION 2 Write a Python program to do the following (a) [2 points] Generate 6 random integers from 10 to 20, inclusive. Store the random
QUESTION 2 Write a Python program to do the following (a) [2 points] Generate 6 random integers from 10 to 20, inclusive. Store the random integers in a list. Name it list1. Display list1 (b) [2 points] Generate 6 random integers from 15 to 25, inclusive. Store the random integers in a list. Name it list2. Display list2 (c) [2 points] Concatenate the first 3 elements of list1 and the last 3 elements of list2 to form a new list. Name it list3. Display list3 (d) [2 points] Concatenate the last 3 elements of list1 and the first 3 elements of list2 to form a new list. Name it list4. Display list4 (e) [2 points] Sort elements of list3 in ascending order (i.e. from small to large). Display the sorted list3 (f) [2 points] Sort elements of list4 in descending order (i.e. from large to small). Display the sorted list4 (g) [2 points] Create a list to store list3 and list4. Name it big_list. This is a list of lists. The first element of biglist is list3. The second element of big_list is list4. Display big_list. (h) [2 points] Use a set of nested loops to display every number in big_list in a separate line. Since there are 12 numbers in big_list, 12 lines of output should be generated (i) [2 points] Use list comprehension to select all the odd integers from list3. Store the result in a list. Display this list of odd integers () [2 points] Use list comprehension to select all the even integers from list4. Store the result in a list. Display this list of even integers The following is an example List 1: [12, 18, 20, 10, 11, 12] List 2: [20, 24, 18, 16, 25, 15 List 3: [12, 18, 20, 16, 25, 15] List 4: [10, 11, 12, 20, 24, 18] List 3 sorted in ascending order: [12, 15, 16, 18, 20, 25] List 4 sorted in descending order: [24, 20, 18, 12, 11, 10] Big List: [12, 15, 16, 18, 20, 25], [24, 20, 18, 12, 11, 10]1 Numbers in big list 12 15 16 18 20 25 24 20 18 12 10 Odd numbers in List 3: [15, 25] Even numbers in List 4: [24, 20, 18, 12, 10]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started