The document contains coding exercises to define functions that take lists as parameters and return new lists or values based on properties of the list elements. The exercises include functions to return even numbers from a list, square the count of elements less than a given integer, remove duplicates from a list, sum elements in odd positions, and count even and odd numbers in a list. Solutions are provided for each exercise.
The document contains coding exercises to define functions that take lists as parameters and return new lists or values based on properties of the list elements. The exercises include functions to return even numbers from a list, square the count of elements less than a given integer, remove duplicates from a list, sum elements in odd positions, and count even and odd numbers in a list. Solutions are provided for each exercise.
The document contains coding exercises to define functions that take lists as parameters and return new lists or values based on properties of the list elements. The exercises include functions to return even numbers from a list, square the count of elements less than a given integer, remove duplicates from a list, sum elements in odd positions, and count even and odd numbers in a list. Solutions are provided for each exercise.
Digital Transformation and Emerging Technologies Coding Lab 7 Exercise 12
• Define the function even_list that takes a list of integers as a
parameter and returns a new list containing only even numbers from the original list. Solution Exercise 13
• Define the function square_count that takes as a parameter a list
of integers and an integer and returns the square of the number of elements in the list that are less than the integer. Solution Exercise 14
• Define the function remove_duplicate that takes a list of
elements as a parameter and returns a new list without duplicate elements. Solution Exercise 15
• Define the function odd_position_sum that takes a list of
numbers as a parameter and returns the sum of all elements of the list in odd positions. Solution Exercise 16
Define the function count_even_odd that takes a list of numbers as
parameters, counts the number of even and odd numbers, and then print these numbers. Example: numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9] Expected Output : “There are 4 even numbers” “There are 5 odd numbers” Solution