Problem 8
Write for loops that iterate over the clements of a list without the use of the range function for the following tasks. a. Printing all elements of a list in a single row, separated by spaces. b. Computing the product of all elements in a list. c. Counting how many elements in a list are negative.
Problem 8
Compute the altemating sum of all elements in a list. For example, if your
program reads the input
then it computes
Problem 9
Write a function that reverses the sequence of elements in a list. For
example, if you call the function with the list
Problem 9
What is an index of a list? What are the legal index values? What is a bounds error?
Problem 11
Write a function def equals
Problem 11
Write a loop that reads ten numbers and a second loop that displays them in the opposite order from which they were entered.
Problem 12
For the operations on lists below, provide the header and function comment for a function. Do not implement the functions. a. Sort the elements in decreasing order. b. Print all clements, separated by a given string. c. Count how many elements are less than a given value. d. Remove all clements that are less than a given value. e. Place all elements that are less than a given value in another list.
Problem 12
Write a function def saneset
Problem 13
Write a function def saneflenents
Problem 15
Write a program that generates a sequence of 20 random die tosses in a list
and that prints the die values, marking only the longest run, like this: