You are on page 1of 11

Luiss

Libera Università Internazionale


degli Studi Sociali Guido Carli

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

You might also like