tag:blogger.com,1999:blog-5181527958781330812021-08-02T22:29:42.899-07:00Python CoursesPython Course For BeginnersMyCourseshttp://www.blogger.com/profile/13135371725353423330noreply@blogger.comBlogger2324125tag:blogger.com,1999:blog-518152795878133081.post-67618258733777899182021-06-25T10:12:00.005-07:002021-06-25T10:12:47.173-07:00Solution Exercise 62: algorithm that multiplies the elements of a given list
Exercise 62
Given a list of integers L, write an algorithm in Python which multiplies the elements of L of even index by 2 and those of odd index by 3.
Example if L = [3, 2, 7, 11, 5, 3], the algorithm returns the list [6, 6, 14, 33, 10, 9]
Solution
<!--Cours Java-->
(adsbygoogle = window.adsbygoogle || []).push({});
def mult (L):
# initialize the searched list
listMult = []
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-81510375040176561952021-06-22T02:10:00.004-07:002021-06-22T02:22:52.357-07:00Getting Started With BootstrapIn this first lesson, we'll start by defining what is Bootstrap.
We then show the advantages as well as the limits of this framework so that you immediately have an idea of the cases where it will be interesting to use it and those where it will be necessary to favor other solutions.
We will finally see the new features brought by version 5 of Bootstrap which is the version with which we will Python Coursehttp://www.blogger.com/profile/11798086417875261951noreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-88097860607182818312021-06-19T08:54:00.004-07:002021-06-19T08:54:32.605-07:00Solution Exercise 61: python algorithm which reverses a given list without using the reverse method
Exercise 61
Resume the previous exercise (Exercise60) without using the reverse() method in python.
Solution
<!-- Java Programming Course -->
(adsbygoogle = window.adsbygoogle || []).push({});
def reverseList (L):
# initialization of the inverted list
lReverse = []
# iterate over the elements of the list L and insert them in an inverted way
for item in L:
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-58802856596652540152021-06-19T08:43:00.001-07:002021-06-19T08:43:28.717-07:00Solution exercise 60: python algorithm that determines the inverse of a list
Exercise 60
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']
Solution
<!-- cours python -->
(adsbygoogle = window.adsbygoogle || []).push({});
def reverseList (L):
# invert the list L
L.reverse ()
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-4457024658516877142021-06-11T00:18:00.001-07:002021-06-11T00:18:08.270-07:00Solution Exercise 55: Python sorting algorithm
Exercise 55
Write an algorithm in Python to sort a list according to the insertion sort algorithm.
Solution
<!-- Python Course -->
(adsbygoogle = window.adsbygoogle || []).push({});
# Python insertion sort algorithm
def sort_insertion (tab):
# Browse from 1 to tab size
for i in range (1, len (tab)):
k = tab [i]
j = i-1
while j >= 0 and k <tab [Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-78518452297194754302021-06-10T11:06:00.005-07:002021-06-10T11:09:54.178-07:00Solution Exercise 54: recursive sum of the elements of a Python list
Exercise 54
Write a Python algorithm as a function which takes as parameter a list of integers L = [n1, n2, n3, ...., np] and which returns the list: [n1, n1 + n2, n1 + n2 + n3, ...., n1 + n2 + ... + np]
Solution
<!-- Java Programming Course -->
(adsbygoogle = window.adsbygoogle || []).push({});
def transformedList (L):
# initialization of the transformed list
lTransformed Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-47698931976063021332021-06-08T09:06:00.001-07:002021-06-08T09:06:08.338-07:00Solution Exercise 53: python algorithm which determines the penultimate index of an element in a list
Exercise 53
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.
Solution
<!-- Python Course -->
(adsbygoogle = window.adsbygoogle || []).push({});
# function which determines the penultimate index of an element in a Python Coursehttp://www.blogger.com/profile/11798086417875261951noreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-72748835781781673492021-06-07T00:44:00.001-07:002021-06-07T00:44:10.249-07:00Solution Exercise 52: python algorithm which determines the list of indexes of an element a in list
Exercise 52
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]
Solution
"""
<!-- python & django -->
(adsbygoogle = window.adsbygoogle || []).push({});
def listIndex(L , a):
# Python Coursehttp://www.blogger.com/profile/11798086417875261951noreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-82266206232272538602021-06-05T00:30:00.005-07:002021-06-05T00:41:09.544-07:00Solution Exercise 51: list of elements duplicated at least 3 times without using any predefined method in Python
Exercise 51
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)
Solution
<!-- python & django -->
(adsbygoogle = window.adsbygoogle || []).push({});
# function which determines the number of Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-36845966529783924872021-06-04T04:25:00.002-07:002021-06-04T04:25:19.234-07:00Solution Exercise 50: list of elements duplicated at least 3 times in Python
Exercise 50
Write a Python algorithm which returns the list of elements duplicated at least 3 times within a given list L .
Solution
<!-- Cours Java -->
(adsbygoogle = window.adsbygoogle || []).push({});
# function which determines the elements duplicated at least 3 times
def duplicate3 (L):
# initialization of the list of duplicated elements at least 3 times
dup3 = []
forPython Coursehttp://www.blogger.com/profile/11798086417875261951noreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-49623680671180194972021-06-03T00:21:00.003-07:002021-06-03T00:24:56.608-07:00Solution Exercise 49: Python algorithm that determines the maximum of elements with even index of a given list
Exercise 49
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.
Solution
<!-- Cours Java -->
(adsbygoogle = window.adsbygoogle || []).push({});
def maxEven (L):
# Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-80888820175034589702021-06-02T08:38:00.004-07:002021-06-02T08:38:59.413-07:00Solution Exercise 48: Python algorithm that determines the sum of elements with odd index of given list
Exercise 48
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.
Solution
<!-- python & django -->
(adsbygoogle = window.adsbygoogle || []).push({});
def oddSum (L):
n = len (L)
# initialize the sum of elements with Python Coursehttp://www.blogger.com/profile/11798086417875261951noreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-61402402420334080792021-05-31T22:16:00.004-07:002021-05-31T22:24:06.167-07:00Solution Exercise 47: Python algorithm that determines the sum of the elements with odd index of a given list
Exercise 47
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.
Solution
<!-- cours python -->
(adsbygoogle = window.adsbygoogle || []).push({});
def oddSum (L):
n = len (L)
# Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-26804344201322821242021-05-30T21:11:00.002-07:002021-05-31T22:19:20.182-07:00Solution 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
<!-- python & django -->
(adsbygoogle = window.adsbygoogle || []).push({});
def listShift (s):
# initialization of the list of capital letters
l_maj = []
for x in s:
if x.isupper ():
Python Coursehttp://www.blogger.com/profile/11798086417875261951noreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-23110420237048582422021-05-28T21:25:00.000-07:002021-05-28T21:25:02.368-07:00Solution 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
<!-- Java Programming Course -->
(adsbygoogle = window.adsbygoogle || []).push({});
# Function which removes integers from a list
def removeInt (L):
# initialize the list obtained from L by removing all Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-25660354837704486722021-05-28T02:01:00.003-07:002021-05-28T02:01:21.832-07:00Solution 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, 0, 0, 7, 11, 25, 16, 14]
Solution
<!-- Python Course -->
(adsbygoogle = window.adsbygoogle || []).push({});
def Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-39810934159875626112021-05-27T13:04:00.005-07:002021-05-27T13:04:35.190-07:00Solution 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
<!-- Cours Java -->
(adsbygoogle = window.adsbygoogle || []).push({});
def deleteNegative(L):
for x in L:Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-41645650067209274082021-05-25T21:48:00.000-07:002021-05-25T21:48:05.034-07:00Solution 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 returns the list: [2, 'even', 11, 'odd', 25, 'odd', 6, 'even', 14, 'even']
Solution
<!-- cours python -->
Python Coursehttp://www.blogger.com/profile/11798086417875261951noreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-27105620079546398012021-05-25T00:00:00.007-07:002021-05-25T00:00:52.384-07:00Solution 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
<!-- Cours Java -->
(adsbygoogle = window.adsbygoogle || []).push({});
def listEvenOdd (L):
# initialization of the list of numbers Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-67827948756931495792021-05-23T21:33:00.001-07:002021-05-23T21:33:13.940-07:00Solution 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
<!-- Cours Java -->
(adsbygoogle = window.adsbygoogle || []).push({});
def listEven (L):
# initialization of the list of numbers that end with an even Python Coursehttp://www.blogger.com/profile/11798086417875261951noreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-3566013008212797462021-05-22T23:33:00.002-07:002021-05-22T23:33:24.199-07:00Solution Exercise 37: python algorithm which determines the list of numbers containing the digit 3
Exercise 37
Write a python algorithm that extracts from a given list of numbers the sublist made up of numbers that contain the digit 3.
Solution
<!-- Java Programming Course -->
(adsbygoogle = window.adsbygoogle || []).push({});
# method which tests whether or not a number contains the digit 3
def contains3 (n):
# convert n to string
s = str (n)
if '3' in s:
Python Coursehttp://www.blogger.com/profile/11798086417875261951noreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-58685139828021710172021-05-21T23:49:00.001-07:002021-05-21T23:49:31.350-07:00Solution Exercise 36: python algorithm which calculates the average of the scores with coefficients
Exercise 36
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
Solution
<!-- cours python -->
(adsbygoogle = window.adsbygoogle || []).push({});
def Python Coursehttp://www.blogger.com/profile/11798086417875261951noreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-47747773442757332012021-05-21T02:09:00.003-07:002021-05-21T02:09:22.206-07:00Solution Exercise 35: python algorithm which determines the list of words containing at least one number and one uppercase
Exercise 35
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']
Solution
<!-- python & django -->
(adsbygoogle = window.adsbygoogle || []).push({});
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-74047825529788761042021-05-20T02:49:00.001-07:002021-05-20T02:49:19.556-07:00Solution Exercise 34: python algorithm which determines the list of words containing at least two digits
Exercise 34
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']
Solution
<!-- Cours Java -->
(adsbygoogle = window.adsbygoogle || []).push({});
# creation of a function Python Coursehttp://www.blogger.com/profile/11798086417875261951noreply@blogger.com0tag:blogger.com,1999:blog-518152795878133081.post-7312184390991126622021-05-20T02:38:00.004-07:002021-05-20T02:38:38.362-07:00Solution Exercise 33: Python program which performs a circular permutation on a list
Exercise 33
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]
Solution
<!-- Java Programming Course -->
(adsbygoogle = window.adsbygoogle || []).push({});
def circularPermutation (L):
Python Coursehttp://www.blogger.com/profile/11798086417875261951noreply@blogger.com0