Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this problem, you will get practice with sorting and slicing lists, and with using list functions such as max ( ) and min ( )

this problem, you will get practice with sorting and slicing lists, and with using list functions such as max() and min().
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. Then print 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, but sorted in increasing order.
The order of the elements in random_list should not be changed. 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

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

Students also viewed these Databases questions

Question

Understanding Groups

Answered: 1 week ago