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
.
Ā