Question
Instruction and Problems Write a Python program for each of the problems in this lab. Please use PyCharm to type and test your programs. Submit
Instruction and Problems
Write a Python program for each of the problems in this lab. Please use PyCharm to type and test your programs. Submit the Python files to Blackboard for credit. In this lab, you should submit 4 Python files, one for each problem.
Problem 2
Write a Python program to do the following:
(A) Use a for loop and a random integer generator to generate 10 random integers in 1 through 15. Store the random integers in a tuple. Display the tuple. [Hint: you may want to store the random integers in a list first and then convert the list to a tuple]
(B) Create a new tuple. Copy the first three elements of the tuple in part (a) to this tuple. Display this tuple.
(C) Create a new tuple. Copy the last three elements of the tuple in part (a) to this tuple. Display this tuple.
(D) Concatenate the two tuples in part (b) and part (c). Display the concatenated tuple.
(E) Sort the concatenated tuple. Display the sorted tuple.
The following is an example. There is no user input in this program.
Tuple of 10 random numbers: (12, 3, 4, 7, 5, 9, 7, 3, 1, 7) Tuple of first 3 numbers: (12, 3, 4) Tuple of last 3 numbers: (3, 1, 7) Two tuples concatenated: (12, 3, 4, 3, 1, 7) Two tuples concatenated and sorted: (1, 3, 3, 4, 7, 12) |
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