1.Create a list that contains 10 successive integers starting with the value in the variable start
. For example, ifΒ start
Β is 7, the resulting list should be [7, 8, 9, 10, 11, 12, 13, 14, 15, 16]. Store the list in a variable namedΒ my_list
. Assume that the value ofΒ start
Β has already been set.
2.Create a list that is made up of the first half of the elements of a list called original_list
. Store the new list in a variable calledΒ half_list
. Assume that the original list has already been initialized and contains an even number of elements.
Β
Β
3. Write a predicate function called same_ends
Β that accepts a list of integers and an integer (n) as arguments. ReturnΒ True
Β if the first n numbers in the list are the same as the last n numbers in the list, andΒ False
Β otherwise. For example, if the list was [1, 2, 3, 4, 99, 1, 2, 3, 4], the function would returnΒ True
Β if n is 4 andΒ False
Β if n is 3. Assume that n is between 1 and the length of the list, inclusive.
Β
4.Write a function calledΒ highest_values
Β that accepts as arguments a list of numeric values and a single integer (n). The function should return a list made up of the largest n values from the argument list in order from lowest to highest. For example, if the argument list is [46, 82, 25, 61, 70, 33, 54] and n is 3, the return value should be [61, 70, 82]. Assume that the argument list contains at least n elements.
Β
5.Assume that a list of integers stored in a variable named original
Β contains exactly two elements that are zero. Write code that creates a separate list that contains the elements fromΒ original
Β that are between the two zeros. Do not include the zeros in the new list. Store the list in a variable namedΒ between_zeros
.
Β
6. Write a function called price_range
Β that accepts a list of floating-point numbers representing prices as an argument and returns the the difference between the highest price and the lowest price. Do NOT use the built-in functionsΒ max
Β orΒ min
Β in your solution. Assume that all prices are positive values and that none of them exceed 10,000.00.
Β
7. Write a function calledΒ count_vowels
Β that accepts a string argument that represents a word and returns the number of vowels that are in the word. The vowels are A, E, I, O, and U (ignore the 'sometimes Y' rule). Count both uppercase and lowercase vowels.
Β
8.
Assume that the variableΒ table
Β holds a two-dimensional list of integers. Write code that computes the sum of all elements in the table, assigning the result to the variableΒ table_sum
.
Β