Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

create a code cell and copy the following code into it ( without the indentations ) . import random random.seed ( 1 2 ) random

create a code cell and copy the following code into it (without the indentations).
import random
random.seed(12)
random_list = random.sample(range(500),99)
This code will create a list named random_list that contains 99 randomly generated integers. We will discuss how this
code works later in the course.
Print the length of random_list. Use list slicing to display the first 10 elements of this list, all on the same line. Format
your output as follows:
Length of random_list: xxxx
First 10 Elements of random_list: xxxx
Use the sum() function to calculate the sum of the elements in random_list. Print the result in the format shown below.
Match the formatting exactly, including the period at the end of the sentence. There should be no space between the
sum and the period.
The sum of the elements in random list is xxxx.
Create a list named sorted_list that contains the same elements of random_list, sorted in increasing order. The
order of the elements in random_list should not be changed. Use slicing to print the first ten elements of both lists on
separate lines. Format your output as follows:
First 10 Elements of sorted_list: xxxx
First 10 Elements of random_list: xxxx
Create lists named bot_slice, mid_slice, and top_slice as follows:
bot_slice should contain the smallest 33 elements in sorted_list.
mid_slice should contain the middle 33 elements in sorted_list.
top_slice should contain the largest 33 elements in sorted_list.
Print the six messages shown below, with the appropriate numerical values inserted in place of the xxxx symbols. Include
the periods at the end of the sentences, and include blank lines between each pair of sentences, as shown.
The smallest element of bot_slice is xxxx.
The largest element of bot_slice is xxxx.
The smallest element of mid_slice is xxxx.
The largest element of mid_slice is xxxx.
The smallest element of top_slice is xxxx.
The largest element of top_slice is xxxx.

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_2

Step: 3

blur-text-image_3

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

Database And Expert Systems Applications 19th International Conference Dexa 2008 Turin Italy September 2008 Proceedings Lncs 5181

Authors: Sourav S. Bhowmick ,Josef Kung ,Roland Wagner

2008th Edition

3540856536, 978-3540856535

More Books

Students also viewed these Databases questions

Question

How is the OSI model used for troubleshooting purposes?

Answered: 1 week ago

Question

What points should we keep in mind while planning out our rsum?

Answered: 1 week ago

Question

Is it clear what happens if an employee violates the policy?

Answered: 1 week ago