Question

In: Computer Science

11. Print the length of the new list out to the screen. Ensure the new list...

11. Print the length of the new list out to the screen. Ensure the new list has a length of 25. 12. Append the integer value 42 to the new list. Print the new list to the screen.   13. Permanently sort the new list. Print the new list to the screen. 14. Remove the integer value 42 from the new list. Print the new list to the screen. 15. Implement a for loop to iterate through the new list. For each list value in the for loop, print the value to the screen after dividing the value by 10 and adding 1. Don’t permanently change the list item value in this process. Note: The math is, as an example, 200/10 + 1 = 21. 16. Print the new list out to the screen one more time to demonstrate the list values did not change during the for loop execution. in python

Solutions

Expert Solution

import random

# creating a list of random number for further assignment.

new_list = [random.randint(0,100) for x in range(25)]

print('Original list:\n', new_list)

#11.

# display the original list

print('\nLength of new list:', len(new_list))

#12.

# append 42 and display list again

new_list.append(42)

print('\nAfter appending 42:\n', new_list)

#13.

# sort the list and display again

new_list = sorted(new_list)

print('\nAfter sorting list:\n', new_list)

#14.

# remove 42 and display list again

new_list.remove(42)

print('\nAfter removing 42:\n', new_list)

#15.

# for each value dispay i / 10 + 1

print('\nEeach value after dividing by 10 and adding 1:')

for i in new_list:

    print((i / 10) + 1, end = ', ')

# display the list again

print()

print('\nOriginal list:\n', new_list)

As you have not mentioned anything about the new_list data, so I chose the random library to fill the list with 25 random numbers. And I fill the array and work on that array as the questions asked.

FOR ANY TYPE OF MODIFICATION AND HELP OR EDIT, PLEASE COMMENT.

FOR HELP PLEASE COMMENT.
THANK YOU


Related Solutions

1. Find and print the length of the list listTest. 2. We can test if an...
1. Find and print the length of the list listTest. 2. We can test if an item exists in a list or not, using the keyword in It will give you a boolean response if a certain element is present. Find whether 'p' or 'P' is present in listTest, and print the results. Print results first for 'p' and then for 'P' as shown in example below. For example: Test Result listTest=['c','i','s','c','1','0','6','P','y','t','h','o','n'] False True 3. We can delete one or...
(C++) Write a program that reads a list of integers from the keyboard and print out...
(C++) Write a program that reads a list of integers from the keyboard and print out the smallest number entered. For example, if user enters 0 3 -2 5 8 1, it should print out -2. The reading stops when 999 is entered.
"PYTHON" Declare a list that is initialized with six of your favorite sports teams. Print out...
"PYTHON" Declare a list that is initialized with six of your favorite sports teams. Print out the number of teams to the shell. Use a for loop to print out the teams to the shell. 2. a. Declare a sporting goods list, initially with no elements. b. Use a while loop to prompt the user for a sporting goods item and append the item to the list. c. Break out of the loop when the user enters exit; do NOT...
What will the following code segments print on the screen? int num = 3; switch (num){...
What will the following code segments print on the screen? int num = 3; switch (num){             case 1:                         System.out.println(“Spring”); case 2:                         System.out.println(“Summer”); case 3:                         System.out.println(“Autumn”); case 4:                         System.out.println(“Winter”); }
import random #the menu function def menu(list, question): for entry in list: print(1 + list.index(entry),end="") print(")...
import random #the menu function def menu(list, question): for entry in list: print(1 + list.index(entry),end="") print(") " + entry) return int(input(question)) plz explain this code
The amount of time Americans spend in front of a screen has a mean of 11...
The amount of time Americans spend in front of a screen has a mean of 11 hours with a standard deviation of 2.7 hours. What is the probability that a random chosen American spends more than 12 hours in front of a screen? Represent the probability with a graph.
Write a complete Java program to print out the name bob
Write a complete Java program to print out the name bob
Question 11 mystring.length() or mystring.size() will return the length of the string in mystring. Question 11...
Question 11 mystring.length() or mystring.size() will return the length of the string in mystring. Question 11 options: True False Question 12 To access an element of an array of structures you use the ________ operator. Question 12 options: Dot Bitwise Logical Comparison Question 13 Question 13 options: What would be printed from the following C++ program? #include #include using namespace std; struct Point { int x; int y; }; void makeTriangle(Point p[]); int main() { Point p[3]; int i; makeTriangle(p);...
Hello, ***We have to print the second list backward while interleaved with the first list in...
Hello, ***We have to print the second list backward while interleaved with the first list in normal order.*** its PYTHON language. Please refer the below example. Bold are the inputs that the user enters. In here the user input words and much as he wants and when he enter STOP, it stops and he is asked to enter more words.(second words count equals to the word count he inputs in the first phase) Enter words, STOP to stop. Ok Enter...
Write a program in Python to print all possible combinations of phone numbers. The length of...
Write a program in Python to print all possible combinations of phone numbers. The length of the number will be given. Also 3 digits will be given, which can not be used. No two consecutive digits can be same. A number containing 4 would always have 4 in the beginning.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT