Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Sample list programs Write a function called negate(myList) which takes in a list of numbers as a parameter and negates each value in the list.

image text in transcribed

Sample list programs Write a function called negate(myList) which takes in a list of numbers as a parameter and negates each value in the list. Since the function changes the list provided as a parameter it does not need to return anything Write a function called negativeCopy(myList), which takes in a list of numbers as a parameter and returns a newly created list, which is, contains the negative values of the original list. For example, For example, negativeCopy(1 -2, 3.5 4.2,] ) would return [-1, 2, -3.5, -4.2] Write a function called addList(myList, addend), which takes in a list of numbers and a single addend as parameters. The function returns a newly created list, which is each number in the original list plus, the addend. For example addList([1,2,3.5,4.2], 3) would return [4, 5, 6.5, 7.2] Write a function called reverseList(myList), which takes in a list of items and returns a newly created list, which is the original list in reverse. For example reverseList( 1, 2, 3.5, 4.2]) would return [4.2, 3.5, 2, 1] Write a function called removeltem(myList,item), which takes in a list and an item and returns a new list with each occurrence of the item removed from the original list. For example, removeltem(1, 2, "the", "test", 3, "is", "the", "best" ], "the") would return [1, 2, "test", 3, "is", "best"] Write a function called sumOf (myList), which takes in a list of numbers as a parameter and returns the sum of all of the values in the list. Write a function called productOf(myList), which takes in a list of numbers as a parameter and returns the product of all of the values in the list. Write a function called count(myList,item), which takes in a list and an item and returns an integer representing how many times the item was in the original list. For example, count(l1, 2, "the", "test", 3, "is", "the", "best" ], "the") would return 2 but count([1, 2, "the", "test", 3, "is", "the", "best" ], "Another") would return 0 (note, I am asking you to do the work here, not use native functionality) Write a function called mean(myList) which takes in a list of numbers and returns a decimal value, which is the mean (the statistical "average") of the numbers in the list. Write a function called median(myList) which takes in a list of numbers and returns the value, which is the arithmetic median of that list (the "middle" value when the list is sorted into order) Write a function called mode(myList), which takes in a list of numbers and returns the value, which occurs in the list the most times

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

Recommended Textbook for

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions

Question

Explain the causes of indiscipline.

Answered: 1 week ago

Question

Explain the factors influencing wage and salary administration.

Answered: 1 week ago