#### Execise 1 || Solution

write python algorithm to display all element of given list by two differents ways.#### Exercise 2 || Solution

write python algorithm to swap the first element with the last element of given list.__Example__: if L =

`["Python" , "Java" , "C++" , "Javascript"]`

, the algorithm returns the list:
`["Javascript", "Java" , "C++" , "Python"]`

#### Exercise 3 || Solution

write a python algorithm as function that takes as parameter a list l and returns a tuple of two lists**(l_old , l_even)**where

**l_old**is make up by the elements of l of

**even**index and

**l_old**is make up by the list element of

**odd**index.

__Example__: if:

`L = ["Python" , "Java" , "C++" , "C#" , "VB.Net" , "Javascript"]`

the algorithm return :
`(['Python', 'C++', 'VB.Net'], ['Java', 'C#', 'Javascript'])`

#### Exercise 4 || Solution

Write a program in Python that asks the user to enter 5 integers of their choice and display the list of numbers entered.

#### Exercise 5 || Solution

Given a list of integers L, write a program in Python that returns the sum of the list L elements.#### Exercise 6 || Solution

Write a Python algorithm that returns the length of a given list without using the len() method.#### Exercise7 || Solution

Write a Python algorithm that returns the list of divisors of a given integer.__Example__if**n = 18**, the algorithm returns the list**[1, 2, 3, 6, 9, 18]**#### Exercise8 || Solution

Write an algorithm in python that returns the average of the terms in a list of numbers.#### Exercise9 || Solution

Write an algorithm in python as a function which takes as parameter a tuple (L, a) formed by a list L and an element a and which returns True if the element a is present in the list L and False if no.#### Exercise 10 || Solution

Write an algorithm in python as a function which takes as a parameter a**tuple (L, x)**formed by a**list L**and an**element x**and which returns the position of the element x in the list L. The function must r**eturn -1**if element x is**not in the list**.#### Exercise 11 || Solution

Write an algorithm in python as a function which takes as parameter a tuple (L, n) formed by a list L of numbers and an integer n and which returns the list obtained from L by multiplying its elements by n . Example if L = [3, 9, 5, 23] and n = 2 the function returns the list: [6, 18, 10, 46]#### Exercise 12 || Solution

Using the sort () method, write an algorithm in python as a function which takes as parameter a list L of numbers and which returns the couple (min, max) formed by the minimum and the maximum of the list.#### Exercise 13 || Solution

Write a python algorithm to remove duplicate elements from a list.#### Exercise14 || Solution

Write a Python program as a function that takes two lists as parameters and returns True if the two lists have at least one common element and False if not.#### Exercise 15 || Solution

Write a Python program in the form of a Python function which takes two lists as parameters and returns the list of elements common to these two lists.#### Exercise 16 || Solution

Write a program in python that randomly mixes the elements of a given list.#### Exercise17 || Solution

Write a Python program that determines the**difference**of two lists.__Example if__:**L1 = [11, 3, 22, 7, 13, 23, 9] L2 = [5, 9, 19, 23, 10, 23, 13]**the program returns the list:**[11, 3, 22, 7]**#### Exercise 18 || Solution

Write a Python program that determines the symmetric difference of two lists L1 and L2, i.e. the list made up of the elements of L1 which are not in L2 and the elements of L2 which are not in L1__Example if__:**L1 = [11, 3, 22, 7, 13, 23, 9] L2 = [5, 9, 19, 23, 22, 23, 13]**The program returns the list**[11, 3, 7, 5, 19]**#### Exercise 19 || Solution

Write an algorithm in python as a function which takes as parameter a list of numbers L and which returns the minimum of the list without using any predefined function in Python.#### Exercise 20 || Solution

Write a Python algorithm which returns the maximum of the list without using any predefined function in Python.#### Exercise 21 || Solution

Write a Python algorithm that returns the list of duplicate elements of a given list.__Example__if**L = [7, 23, 5, 12, 7, 19, 23, 12, 29]**, the algorithm returns the list:**[7, 23, 12]**#### Exercise 22 || Solution

Write an algorithm in python that returns the list of duplicate elements of a given list without using any predefined functions in Python.__Example__if**L = [7, 23, 5, 12, 7, 19, 23, 12, 29]**, the algorithm returns the list**[7, 23, 12]**.#### Exercise 23 || Solution

Write an algorithm in python that returns the number of occurrences of an 'a' element in a given list L without using any predefined functions in Python.#### Exercise 24 || Solution

Write a Python algorithm as a function which takes as parameter a couple (L, a) formed by a list L and an element 'a' and which returns the position of the element 'a' in the list L without using the index() method or any other built-in Python method. The function should return -1 if element 'a' is not present in the list L.#### Exercise 25 || Solution

Write a Python program that determines the list of words**not containing**the**letter 'a'**in a given text.#### Exercise 26 || Solution

For a given list L of integers, write an algorithm in Python that return the tuple of lists**(l_even, l_odd)**where l_even designates the list of even integers of L and l_odd designates the list of odd integers of L.__Example__for**L = [11, 3, 22, 14, 31, 18, 12, 7]**the program returns the pair of lists:**([22, 14, 18, 12], [11, 3, 31, 7])**#### Exercise 27 || Solution

Write a Python algorithm that determines the list of words starting with a capital letter in a given text T.#### Exercise 28 || Solution

Write a Python algorithm that determines the list of words containing at least one capital letter in a given T text.#### Exercise 29 || Solution

Write a Python algorithm that determines the list of words containing at least one digit in a given T text.#### Exercise 30 || Solution

Write a Python algorithm that determines the list of words containing no digits in a given T text.#### Exercise 31 || Solution

For given a list of integers L, write a Python algorithm that returns the list of tuples (n, m) verifying n + m <10.__Example:__if**L = [11, 3, 2, 22, 4, 31, 18, 6, 12, 1, 7]**, the algorithm returns: the list:**[(3, 3), (2, 3), (4, 3), (6, 3), (1, 3), (3, 2), (2, 2), (4, 2), (6, 2), (1, 2), (7, 2), (3, 4), (2, 4), (4, 4), (1, 4), (3, 6), (2, 6), (1, 6), (3, 1), (2, 1), (4, 1), (6, 1), (1, 1), (7, 1), (2, 7), (1, 7)]**#### Exercise 32 || Solution

Write a Python program that move the first 3 elements of a given list and place them at the end of the list.__Example__if**L = [25, 13, 11, 1, 4, 31, 18, 6, 12, 1, 7]**, the program returns: the list:**[1, 4, 31, 18, 6, 12, 1, 7, 25, 13, 11]**#### Exercise 33 || Solution

Write a Python program as a function which takes a list L as a parameter and returns the list obtained by performing a circular permutation on the list L.__Example__if**L = [41, 11, 34, 20, 18, 6]**, the program returns: the list:**[6, 41, 11, 34, 20, 18]**#### Exercise 34 || Solution

Write a Python algorithm as a function which takes a string text T as a parameter and which returns the list of words containing at least two digits.__Example__: if**T = 'Python2.7 is replaced by Python3.X since 2018'**, the function returns the list**['Python2.7', '2018']**#### Exercise 35 || Solution

Write a python algorithm as a function which takes as parameter a string text T and which returns the list of words containing at least one number and one capital letter.__Example__: if**T = 'Python2.7 has been replaced by Python3.X since 2018'**, the algorithm return:**['Python2.7', 'Python3.X']**#### Exercise 36 || Solution

Write a Python algorithm as a function which takes as parameter a couple (listScores, listCoefficients) and which returns the average obtained, where listScores designates the list of scores obtained by a students and listCoefficients designates the list of associated coefficients#### Exercise 37 || Solution

Write a python algorithm that extracts from a given list of numbers the sublist made up of numbers that contain the digit 3.#### Exercise 40 || Solution

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]**#### Exercise 41 || Solution

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]**#### Exercise 42 || Solution

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 returns the list:**[2, 'even', 11, 'odd', 25, 'odd', 6, 'even', 14, 'even']**#### Exercise 43 || Solution

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]**#### Exercise 44 || Solution

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, 0, 0, 7, 11, 25, 16, 14]**#### Exercise 45 || Solution

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.#### Exercise 46 || Solution

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.#### Exercise 47 || Solution

Write a Python algorithm as a function that takes a list L as a parameter and returns the sum of elements of the list L with odd index.__Example__if**L = [3, 2, 5, 11, 21, 4, 7]**, the algorithm returns the number**L[1] + L[3] + L[5] = 2 + 11 + 4 = 17**.#### Exercise 48 || Solution

Write a Python algorithm as a function that takes a list L of numbers as a parameter and returns the sum of elements of L with odd index.__Example__if**L = [3, 2, 5, 11, 21, 4, 7]**, the algorithm returns the number**17**.#### Exercise 49 || Solution

Write a Python algorithm as a function that takes a list L as a parameter and returns the maximum number of elements with even index without using any predefined functions in Python.__Example__if**L = [13, 2, 31, 120, 4, 97, 15]**, the algorithm returns the number**31.**#### Exercise 50 || Solution

Write a Python algorithm which returns the list of elements duplicated at least 3 times within a given list L .#### Exercise 51 || Solution

Write a Python algorithm as a function which takes a list L as a parameter and which returns the list of elements duplicated at least 3 times without using neither the count() method nor any predefined method in Python. (you can use exercise 23)#### Exercise 52 || Solution

Write a Python program as a function which takes as parameters a tuple (L, a) formed by a list L and an element a of L and which returns the list of indexes of a in the list L.__Example__if**L = [2, 7, 11, 7, 21, 39, 7]**and**a = 7**the function returns**[1, 3, 6]**#### Exercise 53 || Solution

Write an algorithm in Python allowing to determine the penultimate index of an element in a list without using any predefined function in Python.__Example__if**L = [2, 7, 11, 7, 21, 39, 7]**and**a = 7**the algorithm returns**3.**#### Exercise 54 || Solution

Write a Python algorithm as a function which takes as parameter a list of integers**L = [n**and which returns the list:_{1}, n_{2}, n_{3}, ...., n_{p}]**[n**_{1}, n_{1}+ n_{2}, n_{1}+ n_{2}+ n_{3}, ...., n_{1}+ n_{2}+ ... + n_{p}]#### Exercise 55 || Solution

Write an algorithm in Python to sort a list according to the insertion sort algorithm.#### Exercise 60 || Solution

Write a Python algorithm that**reverse**the order of the elements of a list using the**reverse() method**.__Example__if**L = ['Java', 'Python', 'PHP', 'C ++']**, the algorithm returns the list:**['C ++', 'PHP', 'Python', 'Java']**#### Exercise 61 || Solution

Resume the previous exercise (Exercise60) without using the reverse() method in python.

**Younes Derfoufi**

my-courses.net

my-courses.net

## No comments:

## Post a Comment