Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a file named Lab 0 6 P 2 . py . Write a Python program to do the following ( note your output should
Create a file named LabPpy Write a Python program to do the following note your output should include the steps being performed:
a Ask the user to enter the number of values that should be in the tuple.
b Ask the user for the start and end values to use when generating a random number.
c Use a for loop and a random integer generator to generate the number random integers indicated by the user in the range that was indicated. Store the random integers in a tuple. Display the tuple as shown in the sample output below.
Hint: You may want to store the random integers in a list first and then convert the list to a tuple.
d Create a new tuple. Copy the first four elements of the tuple in part c to this tuple. Display this tuple as shown below.
e Create a new tuple. Copy the last two elements of the tuple in part c to this tuple. Display this tuple as shown below.
f Concatenate the two tuples in part e and part d Note your program is putting the step e tuple first followed by the step d tuple. Display the concatenated tuple as shown below.
g Add from all the elements in the tuple and display the results. You may need to convert your tuple to a list first, or create a new list, but what you display MUST be a tuple.
Sample output:
Step a:
How many values to put in the tuple?
Step b:
What is the start of the range?
What is the end of the range?
Step c: Tuple of random numbers:
Step d: Tuple of first numbers:
Step e: Tuple of last numbers:
Step f: Two tuples concatenated:
Step g: Two tuples concatenated and incremented:
As shown in the sample output, your output should include which step is being displayed.
Run this program and take a screenshot with the results. Name the screenshot LabPouput.jpg
Sample output:
Step a:
How many values to put in the tuple?
Step b:
What is the start of the range?
What is the end of the range?
Step c: Tuple of random numbers:
Step d: Tuple of first numbers:
Step e: Tuple of last numbers:
Step f: TWO tuples concatenated:
Step g: Two tuples concatenated and incremented:
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