## Solution Exercise 46: list of uppercase letters in a python string

Exercise 46 Write a Python algorithm as a function which takes as parameter a string variable s and which returns the list of all uppercase characters found in s. Solution def listShift (s): # initialization of the list of capital letters l_maj = [] for x in s: if x.isupper (): l_maj.append (x) return l_maj#…

## Solution Exercise 45: python algorithm that removes all integers from a list

Exercise 45 Write a Python algorithm as a function which takes as parameter a list of real numbers L and which returns the list obtained from L by removing all integers. Solution # Function which removes integers from a listdef removeInt (L): # initialize the list obtained from L by removing all integers l_remove_int =…

## Solution Exercise 44: python algorithm for moving the elements of a list

Exercise 44 Write a Python algorithm as a function which takes as a parameter a list of integers L and which returns the list obtained from L by moving all zeros to the beginning of the list. Example if L = [7, 0, 11, 0, 25, 16, 0, 14], the algorithm returns the list: [0,…

## Solution Exercise 43: python algorithm which removes negative elements from a list of numbers

Exercise 43 Write a Python algorithm as a function which takes as parameter a list of integers L and which returns the list obtained from L by removing all negative numbers. Example if L = [7, -2, 11, -25, 16, -3, 14], the algorithm returns the list: [7, 11, 16, 14] Solution def deleteNegative(L): for…

## Solution Exercise 42: even and odd list in python

Exercise 42 Write a Python algorithm as a function which takes as a parameter a list of integers L and which returns the list obtained from L by inserting just after each number the string 'even' or 'odd' depending on the parity of number. Example if L = [2, 11, 25, 6, 14], the algorithm…

## Solution Exercise 41: python algorithm which determines the list of integers whose last digit is even and the second is odd

Exercise 41 Write an algorithm in python that extracts from a list of numbers the sublist of numbers whose last digit is even and the second is odd. Example if: L = [21, 14, 346, 728, 136, 19], the algorithm returns the list: [14, 136] Solution def listEvenOdd (L): # initialization of the list of…

## Solution Exercise 40: python algorithm which determines the list of integers that end with an even number

Exercise 40 Write a Python algorithm that extracts from a list of numbers the sublist of numbers that end with an even number. Example: if L = [21, 14, 346, 728, 13, 19], the algorithm returns the list: [14, 346, 728] Solution def listEven (L): # initialization of the list of numbers that end with…