Answered step by step
Verified Expert Solution
Link Copied!

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 Lab06P2.py. 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 1 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? 8
Step b:
What is the start of the range? 5
What is the end of the range? 25
Step c: Tuple of 8 random numbers: (10,19,9,25,22,11,11,6)
Step d: Tuple of first 4 numbers: (10,19,9,25)
Step e: Tuple of last 2 numbers: (11,6)
Step f: Two tuples concatenated: (11,6,10,19,9,25)
Step g: Two tuples concatenated and incremented: (12,7,11,20,10,26)
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 Lab06P2-ouput.jpg.
Sample output:
Step a:
How many values to put in the tuple? 8
Step b:
What is the start of the range? 5
What is the end of the range? 25
Step c: Tuple of 8 random numbers: )
Step d: Tuple of first 4 numbers: (10,19,9,25)
Step e: Tuple of last 2 numbers: (11,6)
Step f: TWO tuples concatenated: (11,6,10,19,9,25)
Step g: Two tuples concatenated and incremented: (12,7,11,20,10,26)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions

Question

How is a C Corporation subject to double taxation?

Answered: 1 week ago

Question

5. Describe the visual representations, or models, of communication

Answered: 1 week ago