Question

Use the list functions learned in class to perform a series of operations and display the...

Use the list functions learned in class to perform a series of operations and display the output using the following list – [5, 15, 84, 3, 14, 2, 8, 10, 14, 25]. Specifications are as follows:

(a) Print a count of the number of times 14 is in the list. (worth 2 pts)

(b) Print the maximum number in the list. (worth 2 pts)

(c) Print the minimum number in the list. (worth 2 pts)

(d) Print the numbers in the list in reverse order. (worth 2 pts)

(e) Sort the list and print the sorted list. (worth 2 pts)

(f) Print one number randomly chosen from the list. (worth 2 pts)

(g) Randomly shuffle the list and print the output. (worth 2 pts)

(h) Make a deepcopy of the list, change one number in the copied list, then print the original list and the copied list. (worth 6 pts)

Note: You must use list functions to complete all items above.

Your output should look like this:

(a) Count of the number 14 - 2

(b) Maximum number – 84

(c) Minimum number – 2

(d) Reverse list – [25, 14, 10, 8, 2, 14, 3l, 84, 15, 5]

(e) Sorted list – [2, 3, 5, 8, 10, 14, 14, 15, 25, 84]

(f) Random number – 10 (note: could be any number in the list, not necessarily 10)

(g) Shuffled list – [14, 10, 2, 14, 25, 31, 5, 15, 84, 8] (note: your shuffled list may be different)

(h) Original list – [5, 15, 84, 3, 14, 2, 8, 10, 14, 25] Copied list – [5, 15, 83, 3, 14, 2, 8, 10, 14, 25] (note: this assumes you changed the number 84 to 83 in the copied list)

Homework Answers

Answer #1
Thanks for the question.

Below is the code you will be needing  Let me know if you have any doubts or if you need anything to change.

Thank You !!

===========================================================================

numbers=[5, 15, 84, 3, 14, 2, 8, 10, 14, 25]
#a
print('Count of the number 14 -{}'.format(numbers.count(14)))
#b
print('Maximum number - {}'.format(max(numbers)))
#c
print('Minimum number - {}'.format(min(numbers)))
#d
numbers.reverse()
print('Reverse list - {}'.format(numbers))
#e
numbers.sort()
print('Sorted list - {}'.format(numbers))
#f
import random
print('Random number - {}'.format(random.choice(numbers)))
#g
random.shuffle(numbers)
print('Shuffled list - {}'.format(numbers))
#h
numbers=[5, 15, 84, 3, 14, 2, 8, 10, 14, 25]
deep_copy=[n for n in numbers]
deep_copy[2]=deep_copy[2]+1
print('Original list - {}'.format(numbers))
print('Copied list - {}'.format(deep_copy))

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Python Design a class named IP_address to represent IP address objects. The IP_address class contains the...
Python Design a class named IP_address to represent IP address objects. The IP_address class contains the following A number of instance variables/fields to store a table of data. You can design them by your own. A constructor that creates a table with the following: a list of data. ip address a integer to indicate the number of elements in the sum_list/freq_list/average_list A get_ip_address() method that returns the ip address For example, consider the following code fragment: ip_key = '192.168.0.24' data_list...
Python Design a class named IP_address to represent IP address objects. The IP_addressclass contains the following...
Python Design a class named IP_address to represent IP address objects. The IP_addressclass contains the following A number of instance variables/fields to store a table of data. You can design them on your own. A constructor that creates a table with the following: a list of data. IP address an integer to indicate the number of elements in the sum_list/freq_list/average_list A get_ip_address() method that returns the IP address For example, consider the following code fragment: ip_key = '192.168.0.24' data_list =[(0,...
1. _____________ means operating an array, such as object or list, or doing operations element by...
1. _____________ means operating an array, such as object or list, or doing operations element by element.        Vectorization        Standardrization 2. What would be the output of the range function: start= 10 stop = 20 step = 2 range (start, stop, step) 3. The below code x=2 for x in range(x+1,x+8): print(x, end=" ") will print 4. Which of the below numpy attributes describe the number of rows and number of the columns in the array   ...
Use Python to Complete the following on a single text file and submit your code and...
Use Python to Complete the following on a single text file and submit your code and your output as separate documents. For each problem create the necessary list objects and write code to perform the following examples: Sum all the items in a list. Multiply all the items in a list. Get the largest number from a list. Get the smallest number from a list. Remove duplicates from a list. Check a list is empty or not. Clone or copy...
Write a function count_div5(nested_list) that takes in a list of lists of integers, and returns a...
Write a function count_div5(nested_list) that takes in a list of lists of integers, and returns a list of integers representing how many integers in each sublist of the original were divisible by 5. Examples: >>> count_div5([[5, 3, 25, 4], [46, 7], [5, 10, 15]]) [2, 0, 3] >>> count_div5([]) [] >>> count_div5([[-20, 10, 2, 4, 5], [], [5], [8, 25, 10], [6]]) [3, 0, 1, 2, 0]
In this example you are allowed to use from the C standard library only functions for...
In this example you are allowed to use from the C standard library only functions for input and output (e.g. printf(), scanf()) Complete the following functions using C programming language: A positive integer number is said to be a perfect number if its positive factors, including 1 (but not the number itself), sum to the number. For example, 6 is a perfect number because 6=1+2+3. Complete the int Q6(intQ6_input, int perfect[])function that determines all perfect numbers smaller than or equal...
You can complete this assignment individually or as a group of two people. In this assignment...
You can complete this assignment individually or as a group of two people. In this assignment you will create a ​​Sorted Singly-Linked List​ that performs basic list operations using C++. This linked list should not allow duplicate elements. Elements of the list should be of type ‘ItemType’. ‘ItemType’ class should have a private integer variable with the name ‘value’. Elements in the linked list should be sorted in the ascending order according to this ‘value’ variable. You should create a...
IN C++ AS SIMPLE AS POSSIBLE ______ Re-write the given function, printSeriesSquareFifth,  to use a while loop...
IN C++ AS SIMPLE AS POSSIBLE ______ Re-write the given function, printSeriesSquareFifth,  to use a while loop (instead of for). • The function takes a single integer n as a parameter • The function prints a series between 1 and that parameter, and also prints its result • The result is calculated by summing the numbers between 1 and n (inclusive). If a number is divisible by 5, its square gets added to the result instead. • The function does not...
6. Using the class data (see Blackboard file - "Class Survey Data - PSS-10 and GAS")...
6. Using the class data (see Blackboard file - "Class Survey Data - PSS-10 and GAS") calculate the correlation between the GAS – Goal disengagement and the GAS – Goal reengagement scores. Write the results in a statistical statement. 7. Using the class data calculate the correlation between the GAS – Goal disengagement and the PSS-10 scores. Write the results in a statistical statement. 8. Using the class data calculate the correlation between the GAS – Goal reengagement scores and...
Lab 6    -   Program #2   -   Write one number to a text file. Use the write()...
Lab 6    -   Program #2   -   Write one number to a text file. Use the write() and read() functions with binary                                                        data, where the data is not char type.              (Typecasting is required) Fill in the blanks, then enter the code and run the program. Note:   The data is int type, so typecasting is            required in the write() and read() functions. #include <iostream> #include <fstream> using namespace std; int main() {    const int SIZE = 10;   ...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT