in pythonCreate a new Python program (you choose the filename) that contains a main function and another function named change_list. Refer to the SAMPLE OUTPUT after reading the following requirements.In the main function:create an empty list.use a for loop to add 12 random integers, all ranging from 50 to 100, to the list.use second for loop to iterate over the list and display all elements on one line separated by a single space.display the 4th element, the element at index 9, and the smallest element.call the change_list function with your list as its sole argument.In the change_list function:use a slice to make a new list from the list that was passed into this function. The new list should hold the middle 6 elements of the list that was passed in. NOTE: you must accomplish this step with a slice.use a function to determine the size of the new list. Print the size.sort the new list in ascending order and return the sorted list to main.Back in the main function:assign the list returned by change_list to a new list.use another for loop to iterate over this returned list and display all elements on one line, separated by a single space.SAMPLE OUTPUTHere is the list of random integers...99 66 57 81 75 59 58 74 56 90 75 65The 4th element in the list is 81The element at index 9 is 90The smallest element in the list is 56The size of the list is now 6change_list returned this sorted list...56 58 59 74 75 81

Question
Asked Oct 5, 2019
51 views

in python

Create a new Python program (you choose the filename) that contains a main function and another function named change_list. Refer to the SAMPLE OUTPUT after reading the following requirements.

In the main function:

  • create an empty list.
  • use a for loop to add 12 random integers, all ranging from 50 to 100, to the list.
  • use second for loop to iterate over the list and display all elements on one line separated by a single space.
  • display the 4th element, the element at index 9, and the smallest element.
  • call the change_list function with your list as its sole argument.

In the change_list function:

  • use a slice to make a new list from the list that was passed into this function. The new list should hold the middle 6 elements of the list that was passed in. NOTE: you must accomplish this step with a slice.
  • use a function to determine the size of the new list. Print the size.
  • sort the new list in ascending order and return the sorted list to main.

Back in the main function:

  • assign the list returned by change_list to a new list.
  • use another for loop to iterate over this returned list and display all elements on one line, separated by a single space.

SAMPLE OUTPUT
Here is the list of random integers...
99 66 57 81 75 59 58 74 56 90 75 65
The 4th element in the list is 81
The element at index 9 is 90
The smallest element in the list is 56
The size of the list is now 6
change_list returned this sorted list...
56 58 59 74 75 81

check_circle

Expert Answer

Step 1

Create a main function in the program.

Create an empty list, the name of the list is randomNumber.

Use the random function to add 12 elements in the list. The range of elements is from 50 to 100.

display all elements of the list.

Display the fourth element of the list.

Display the elements in which the index is 9.

Display the smallest...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Python

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: Write a Java class, XXX_Lab7-3, where XXX is your Kean email ID. In the main method:* Create an arra...

A: Writing a java Program to create a class name XXX_Lab7-3. In this program there are two arrays, one ...

question_answer

Q: Write two cin statements to get input values into birthMonth and birthYear. Then write a statement t...

A: Program Code:#include <iostream>using namespace std;int main(){  int birthYear, birthMonth;  c...

question_answer

Q: Write a python code of a function that takes in four points in a counterclockwise order, a, b, c, d ...

A: Program Instructions:Create a function isConvex() and pass the four points as arguments.Save the par...

question_answer

Q: What exactly is Boolean?

A: BooleanBoolean also known as Boolean logic is actually a subset of algebra used for creating true or...

question_answer

Q: program6_1.pyWrite a program that the owner of Chica Chic could use to store data about her inventor...

A: Since you have not provided the sample text file for this problem, we have created a text file inven...

question_answer

Q: Can someone offer an explanation to these few simple questions please?

A: Click to see the answer

question_answer

Q: Hello, I am using the Intro to Java programmming and data structures by Y. Daniel Liang. Our profess...

A: A java program to check the user’s input is a factor of random number generated is given below;Progr...

question_answer

Q: Write a program in Java Eclipse that does the following:a) create a 2D Ragged array with columns and...

A: Create a Main class and all required methods to print Ragged array elements. And create all methods ...

question_answer

Q: create a new file in c++. In this lab, you will add some more functionality to the program. Use loop...

A: Program Instructions:Declare variables and write a welcome message.Always convert the user's choice ...