Question: In this problem, you will create a program from scratch based to demonstrate your abilities to create and manipulate lists in Python. Create a file
In this problem, you will create a program from scratch based to demonstrate your abilities to create and manipulate lists in Python.
Create a file named LabPpy
For this program:
Label each block of code that performs the different steps with an appropriate comment eg # Step a
Your output should also include indications as to what step is being displayed. See the Sample Output for an example.
Remember to put your program in a main function and call main at the end of your file.
Write a Python program that performs the following steps:
a Ask the user for the lower and upper bound for generating random numbers.
b Ask the user how many numbers they want in the lists. This number will determine the size of BOTH lists.
c Use a for loop and a random integer generator to generate random integers from lower to upper bounds the user specified in step a This is an inclusive range. The program should generate the number of integers indicated by the user in step b Store the random integers in a list. Display the list.
d Create a second list in the same way as was done in step b Display the second list.
NOTE: You could create a function that generates a list like what is specified in steps c and d To do that, pass in the numbers from steps a and b as parameters, and then return the list that is generated.
e Use a for loop to display the elements in the two lists in pairs, ie display the first elements in both lists, display the second elements in the both lists, etc.
HINT: Have your for loop increment through the lists using an index. That will allow you to access the th elements, then the st elements, etc.
f Combine the lists into a single list and display the combined list.
g Sort the combined list in place and display the sorted combined. Do NOT use the sorted function. Use the method we learned about in class.
h Use list slicing to display the first three elements in the list and the last three elements in the list.
i Display the total of the elements in the list. Use a single function to calculate that total.
j Display the minimum element in the list. Use a single function to determine that element.
k Display the maximum element in the list. Use a single function to determine that element.
l Use a for loop and a random integer generator to generate random integers in the range specified by the user in step a Check if each number is in the combined list.
If the number is in the combined list, print the number and print the index of the first element that matches.
NOTE: There is a list method for finding an element value which return the index and you should use that function. Do NOT use a for loop or you will lose some points.
If the element is found, after printing the index, the element should be deleted or removed from the list.
NOTE: There is both a function and a list method that can delete or remove an element from a list. You should use either the function or the list method. Do NOT use a for loop or you will lose some points.
If the number is not in the combined list, print the number followed by "not found in list".
m Print the combined list now that elements may have been deleted.
Sample output:
Step a: How many numbers in each list?
Step b:
What is the lower bound for the random number?
What is the upper bound for the random numbers?
Step c: First list:
Step d: Second list:
Step e:
Step f: Combined list:
Step g: Sorted list:
Step h:
First three elements:
Last three elements:
Step i: Sum:
Step j: Minimum:
Step k: Maximum:
Step l:
at index
at index
not found in list
at index
not found in list
Step m: Final list:
Run this program using the PyCharm Terminal. Take a screenshot of the Terminal that includes the line showing where you started the program run with the results. Name the screenshot LabPouput.jpg
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
