## Solution 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 def mult…

## Getting Started With Bootstrap

In 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…

## Solution 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 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: lReverse.insert (0, item) return lReverse# ExampleL = ['Java',…

## Solution 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 def reverseList (L): # invert the list L L.reverse () return L# ExampleL = ['Java',…

## Solution Exercise 55: Python sorting algorithm

Exercise 55 Write an algorithm in Python to sort a list according to the insertion sort algorithm. Solution # Python insertion sort algorithmdef 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 [j]: tab…

## Solution 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 def transformedList (L): # initialization of the transformed…

## Solution 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 # function which determines the penultimate index of an…