## 1 - What is the QMainWindow Class ?

The QMainWindow class has been specially designed to manage the main window of your application when it is complex. Among the features offered to us by the QMainWindow class, we find in particular the menus, the toolbar and the status bar. The QMainWindow class inherits directly from QWidget. It is a widget that is generally used once per program and is only used to create the main window of the application.

#### Note:

Simple pyqt applications won't need to use the QMainWindow class, they just use the QWidget class.

## 1 - Principle And Syntax Of Blogger Conditional Tags

The principle of using conditional tags is simple: a condition is defined and the content will be executed according to a particular case. These tags can be inserted in the HTML code of the template as well as in an HTML / Js gadget.

#### In general, the syntax is as follows:

``````If Condition
---  Run this part ---
Else
--- Perform this other part ---
End if``````

## Thursday, September 30, 2021

#### Exercice 61

Write a program in Python that asks the user to enter five integers of their choice and return them a dictionary whose keys are the entered numbers and whose values are the lists of the divisors of the entered numbers. Example if the user enters the numbers: 14, 7, 8, 6, 13 the program returns the dictionary:
``d = {14: [1, 2, 7, 14], 7: [1,7], 8: [1, 2, 4, 8], 6: [1,3,6], 13: [1, 13]}``

## Monday, September 27, 2021

#### Exercise 94 *

Write a Python algorithm which extract from a string text the list of words whose first character is identical to the last. Example if s = "radar number 212", the algorithm returns the list ['radar', '212']

## Saturday, September 18, 2021

#### Exercise 93 *

Write an algorithm in python which transforms a list of integers L = [n1, n2, n3, ...., np] into the list of factorials: [n1! , n2! , n3!, ...., np!]

## Friday, September 17, 2021

#### Exercise 92**

Write a python algorithm which transforms a list of integers
``L = [n1, n2, n3, ...., np]``
into a list whose elements are the averages of the partial sums:
``[n1, average(n1, n2) , average(n1, n2, n3), ...., average(n1, n2, ..., np)]``

## Thursday, September 16, 2021

#### Exercise 91 **

Write an algorithm in python as a function that transforms a string text T into a list where words containing numbers are placed at the end of the list. Example if T = "Python_1 created in 1991. Currently it is in version Python_3.9" the algorithm returns the list: ['created', 'in', 'Currently', 'it', 'is', 'in', 'version', 'Python_1', '1991.', 'Python_3.9' ]

## Wednesday, September 15, 2021

#### Exercise 97 *

Write a python algorithm as a function which takes as parameter a couple (s, x) formed by a text string s and a char x and which returns the index of the second position of the character x in the string s without using no predefined function. The function should return -1 if the char x is not in the string s. Example if s = 'python programming language' and x = 'p', the function returns the index: 7

## Tuesday, September 14, 2021

#### Exercise 96 *

Write an algorithm in Python as a function which takes a text string as parameter and which returns the list of words containing at least two uppercase letters. Example if
`` s = 'The PySide GUI library is more popular than PyQt'``
, the function returns the list:
``['GUI', 'PySide', 'PyQt']``

## Monday, September 13, 2021

#### Exercise 90 *

Given a list of integers
``L = [n1, n2, n3, ..., np]``
, write an algorithm in python which returns the list:
``L_sum = [n1, n1 + n2, n1 + n2 + n3, .. ., n1 + n2 + n3 + ... + np]``

#### Solution

``````# function which calculates the sum of the list elements
def sumList (L):
# initialization of the sum of the list elements
s = 0
for x in L:
s = s + x
return s

# function which determines the list L_sum
def sum_list (L):
# initializationh of the list L_sum
L_sum = []
for i in range (0, len (L)):
L_sum.append (sumList (L [0: i+1]))

return L_sum

# Example
L = [3, 2, 5, 1, 0, 7]
print ("L_sum =", sum_list (L))``````

Younes Derfoufi
my-courses.net

## Sunday, September 12, 2021

#### Exercise 89 *

Given a list L, write a python algorithm which returns the list of digits contained within the elements of list L without repetition. Example if L = ["Python3", 91, "Java2", 95], the algorithm returns the list [3, 9, 1, 2, 5]

## Saturday, September 11, 2021

#### Exercise 88 *

Given a list L, write a python algorithm which returns the list of digits contained within the elements of the list L. Example if L = ["Python3", 91, "Java2", 95], the algorithm returns the list [3, 9, 1, 2, 9, 5]

## Friday, September 10, 2021

#### Exercise 87

Given a list L, write a Python algorithm to convert a list into a string without using any predefined method other than the str() method. Example if L = ["Python", "created on", 91, "by Guido Van Rosam"], the algorithm returns the string s = "Python created on 91 by Guido Van Rosam".

#### Exercise 86

Given a list L, write a python algorithm which returns the list of integer elements of L. Example: if
`` L = ["Python3", 91, "Java2", 95]``
, the algorithm returns the list
``[91, 95]``

## Thursday, September 9, 2021

#### Exercise 85

Write a python program which that move the null values of a list to the end of the list while keeping the order of the other non-null elements. Example if the list is: L = [7, 0, 11, 5, 0, 21, 0, 2, 0, 0, 9] the output is: [7, 11, 5, 21, 2, 9, 0, 0, 0, 0, 0]

## Wednesday, September 8, 2021

#### Exercise 84

96 is an integer whose tens digit is divisible by 3 (property (*)) Given an integer n, write an algorithm in python which returns the list of integers less than or equal to n composed of two digits and checking the property (*)

#### Exercise 83

Write a python algorithm which replaces the elements of even index by 2 and the elements of odd index by 1.

#### Solution

``````# function which replaces the elements of even index by 2 and the elements of odd index by 1
def replace (L):

# initialization of the searched list
list_2_1 = []

for i in range (0, len (L)):
if i% 2 == 0:
list_2_1.append (2)
else:
list_2_1.append (1)
return list_2_1

# Example
L = ["Python", "Java", "C ++", "C #", "Javascript"]
print (replace (L)) # print: [2, 1, 2, 1, 2]``````

Younes Derfoufi
my-courses.net

## Tuesday, September 7, 2021

#### Exercise 82

Write a program in Python which determines the list of words containing two successive identical characters in a character string s. Example if s = "Python is the most recommended programming language", the algorithm returns the list
`` ["recommended", "programming"].``

## Monday, September 6, 2021

#### Exercise 79

Write using the count() method, a python algorithm as a function which takes as parameter a list of integers L and which returns without repetitions the list of tuples (n, occ_n) formed by the elements n of L and their occurrence occ_n. Example: if
``L = [22, 7, 14, 22, 7, 14, 7, 14, 11, 7],``
the algorithm returns the list
``[(22, 2), (7, 4), (14, 3 ), (22, 1), (11, 1)]``

#### Exercise 78

Given a list made up of the students' averages avg_list, write a python algorithm that determines the first index of the average which is less than 10. Example if
``avg_list = [12, 17, 10, 7, 11, 14, 15, 9]``
, the algorithm returns index 3.

#### Exercise 77

Repeat the previous exercise (Exercise 76) without using the max() method.

#### Exercise 76

Write a Python algorithm that determines the first index of the maximum in a given list using the max () method. Example if
``L = [22, 7, 88, 41, 14, 88, 9]``
, the algorithm returns the first index of the maximum which is 2.

#### Exercise 75

Write a Python algorithm to reverse a list without using the reverse() method

## Sunday, September 5, 2021

#### Exercise 74

Write a Python algorithm that asks the user to enter successively 7 integers and display the list of numbers entered by ignoring repeated numbers. Example if the user enters the numbers: 2, 11, 3, 2, 3, 5, 2. the algorithm returns the list
``[2, 11, 3, 5]``

#### Exercise 73

Write a function which takes as parameter a variable of type string s and another string T, and returns the list of positions of a pattern s in the string T. The function must return the empty list if the pattern s does not appear in the text T.

#### Exercise 46

1. Define a Book class with the following attributes: Title, Author (Full name), Price.
2. Define a constructor used to initialize the attributes of the method with values entered by the user.
3. Set the View() method to display information for the current book.
4. Write a program to testing the Book class.

## Saturday, September 4, 2021

#### Exercise 45. Computation class:

1 - Create a Coputation class with a default constructor (without parameters) allowing to perform various calculations on integers numbers.
2 - Create a method called Factorial() which allows to calculate the factorial of an integer. Test the method by instantiating the class.
3 - Create a method called Sum() allowing to calculate the sum of the first n integers 1 + 2 + 3 + .. + n. Test this method.
4 - Create a method called testPrim() in  the Calculation class to test the primality of a given integer. Test this method.
4 - Create  a method called testPrims() allowing to test if two numbers are prime between them.
5 - Create a tableMult() method which creates and displays the multiplication table of a given integer. Then create an allTablesMult() method to display all the integer multiplication tables 1, 2, 3, ..., 9.
6 - Create a static listDiv() method that gets all the divisors of a given integer on new list called  Ldiv. Create another listDivPrim() method that gets all the prime divisors of a given integer.

#### Exercise 44. Circle class

1 - Define a Circle class allowing to create a circleC (O, r) with center O(a, b) and radius r using the constructor:
``````    def __init__(self,a,b,r):
self.a = a
self.b = b
self.r = r
``````
2 - Define a Area() method of the class which calculates the area of ​​the circle.
3 - Define a Perimeter() method of the class which allows you to calculate the perimeter of the circle.
4 - Define a testBelongs() method of the class which allows to test whether a point A(x, y) belongs to the circle C(O, r) or not.

#### Exercise 72

Write a function which takes an element x and a list L as a parameter, and returns the list of positions of x in L. The function must return the empty list if the element x does not appear in the list L.

#### Exercise 71

Write a Python algorithm that transforms a list of integers L = [n1, n2, n3, ..., np] by adding 1 to the first element, 2 to the second element, 3 to the third element, ..., p to the pth element. The algorithm must return at the end the list
``[n1 + 1, n2 + 2, n3 + 3, ..., np + p]``
.

## Friday, September 3, 2021

#### Exercise 70

Write a Python algorithm to test if a given list is symmetric using the reverse() method. Example: for L1 = [2, 5, 11, 5, 2] the algorithm returns True and for L2 = [2, 23, 11, 51, 7] the algorithm returns False.

#### Exercise 69

Write a Python algorithm which determines for a given integer n the list of tuples of integers (p, q) satisfying:
``p2 + q2 = n``

## Thursday, September 2, 2021

#### Exercise 68

Write a Python algorithm which determines for a given integer, the list of perfect squares between 1 and n. Example if n = 100 the algorithm returns the list
``[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]``

#### Exercise 67

Write without using any predefined function a Python algorithm as a function which takes as parameter a list of integers L and which returns True if the list is arranged in ascending order and False if not.

#### Exercise 66

Write a Python algorithm to extract the list of integers from a list of numbers. Example: if
``L = [2.5 , 11.54 , 3 , 7.35 , 5 , 6.5 , 9]``
, the algorithm returns the list
``[3, 5, 9]``

#### Exercise 65

Given a list of strings, write a Python algorithm allowing which replace the elements of the list with their lengths. Example: if
`` L = ["Python", "Django", "Numpy", "Sympy"]``
, the algorithm returns the list
``[6, 6, 5, 5]``

## Tuesday, August 31, 2021

#### Exercise 63

Write a program in python allowing to extract from a list of strings, the list of strings containing at least two vowels. Example if
``L = ["Java", "Python", "Dart", "MySql"]``
, the program returns the list
``["Java", "Python"]``
.

## Friday, August 20, 2021

``````my_globvar = 0

def change_globvar():
global my_globvar    # Needed to modify m_globvar
my_globvar = 1

# we can change value of global variable
change_globvar()
print(my_globvar)``````

Younes Derfoufi
my-courses.net
``````x = 10
print(type(x))// type int
x = float(x)
print(type(x))// flot type``````

Younes Derfoufi
my-courses.net
``````x = 5
print (type (x)) # x is of type int
x = "Hello World"
print (type (x)) # x is now of type string``````

Younes Derfoufi
my-courses.net

## Friday, June 25, 2021 #### 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]

## Tuesday, June 22, 2021

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 finally see the new features brought by version 5 of Bootstrap which is the version with which we will be working and will take the opportunity to set up our working environment.

## What is Bootstrap?

Bootstrap is a CSS framework. A framework corresponds to a set of libraries grouped together for a specific purpose and having internal rules that users must follow. In other words, and to put it very simply, Bootstrap is a collection of CSS and JavaScript files that work together and that we can use to create complex designs in a relatively simple way. The Bootstrap framework is therefore a set of CSS and JavaScript files which contain predefined rules and which define components. These rule sets are enclosed in classes so we will only have to use the classes we are interested in in order to apply a set of styles to a particular HTML element. In addition, Bootstrap also uses JavaScript files and in particular external JavaScript libraries like jQuery or Popper to define entire components like navigation bars, modal windows, etc. which we will also be able to directly implement.

## Saturday, June 19, 2021 #### Exercise 61

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

#### Solution #### 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']

## Friday, June 11, 2021 #### Exercise 55

Write an algorithm in Python to sort a list according to the insertion sort algorithm.

## Thursday, June 10, 2021 #### 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]

## Tuesday, June 8, 2021 #### 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.

## Monday, June 7, 2021 #### 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]

"""

## Saturday, June 5, 2021 #### 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)

## Friday, June 4, 2021 #### Exercise 50

Write a Python algorithm which returns the list of elements duplicated at least 3 times within a given list L .

## Thursday, June 3, 2021 #### 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.

## Wednesday, June 2, 2021 #### 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.

## Monday, May 31, 2021 #### 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 + L + L = 2 + 11 + 4 = 17.

## Sunday, May 30, 2021 #### 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.

## Friday, May 28, 2021 #### 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 #### 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]

## Thursday, May 27, 2021 #### 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]

## Tuesday, May 25, 2021 #### 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 #### 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]

## Sunday, May 23, 2021 #### 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]

## Saturday, May 22, 2021 #### 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.

## Friday, May 21, 2021 #### 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 #### 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']

## Thursday, May 20, 2021 #### 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 #### 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]

## Wednesday, May 19, 2021 #### Exercise 32

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]

#### Solution #### Exercise 31

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)]

#### Solution #### Exercise 30

Write a Python algorithm that determines the list of words containing no digits in a given T text.

## Monday, May 17, 2021 #### Exercise 29

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

#### Solution #### Exercise 28

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

#### Solution #### Exercise 27

Write a Python algorithm that determines the list of words starting with a capital letter in a given text T.

#### Solution #### Exercise 26

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])

#### Solution #### Exercise 25

Write a Python program that determines the list of words not containing the letter 'a' in a given text.

## Tuesday, May 11, 2021 #### Exercise 24

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.

#### Solution #### Exercise 23

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. Example if L = [7, 23, 5, 23, 7, 19, 23, 12, 29] and a = 23, the algorithm returns 3.

## Friday, May 7, 2021

#### Exercise 22

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].

#### Solution #### Exercise 21

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]

#### Solution #### Exercise 20

Write a Python algorithm which returns the maximum of the list without using any predefined function in Python.

## Thursday, May 6, 2021 #### Exercise 19

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.

#### Solution #### Exercise 18

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]

#### Solution

``````def symetricDifference(L1 , L2):
# initialiser la liste difference sysmétrique de L1 et L2
diffSym = []
for x in L1:
if x not in L2:
diffSym.append(x)
for x in L2:
if x not in L1:
diffSym.append(x)
return diffSym
#Example
L1 = [11 , 3 , 22 , 7 , 13 , 23 , 9]
L2 = [5 , 9 , 19 , 23 , 22 , 23 , 13]
print("The symetric difference of L1 and L2 is : " , symetricDifference(L1 , L2))
# The output is: The symetric difference of L1 and L2 is :  [11, 3, 7, 5, 19]``````

Younes Derfoufi
my-courses.net #### Exercise17

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]

## Tuesday, May 4, 2021

#### Exercise 16

Write a program in python that randomly mixes the elements of a given list.

## Monday, May 3, 2021 #### Exercise 15

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.

#### Solution #### Exercise14

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.

#### Solution #### Exercise 13

Write a python algorithm to remove duplicate elements from a list.

#### Exercise 95*

Write a Python function to get any string/sentence and returns the most repeated word.

#### Exercise 94*

Write a Python program as function that takes as parameter a string s and which returns the list repeated word within the string s. Example: if s = "Python is object oriented programming language. Python is also also used for data sciences", the fuction returns the list: ['Python', 'is', 'also']

## Saturday, April 17, 2021

1. capitalize() Converts the first character to upper case
2. casefold() Converts string into lower case
3. center() Returns a centered string
4. count()         Returns the number of times a specified value occurs in a string
5. encode() Returns an encoded version of the string
6. endswith() Returns true if the string ends with the specified value
7. expandtabs() Sets the tab size of the string
8. find()         Searches the string for a specified value and returns the position of where it was found
9. format() Formats specified values in a string
10. format_map() Formats specified values in a string
11. index()  Searches the string for a specified value and returns the position of where it was found
12. isalnum() Returns True if all characters in the string are alphanumeric
13. isalpha() Returns True if all characters in the string are in the alphabet
14. isdecimal() Returns True if all characters in the string are decimals
15. isdigit() Returns True if all characters in the string are digits
16. isidentifier() Returns True if the string is an identifier
17. islower() Returns True if all characters in the string are lower case
18. isnumeric() Returns True if all characters in the string are numeric
19. isprintable() Returns True if all characters in the string are printable
20. isspace() Returns True if all characters in the string are whitespaces
21. istitle() Returns True if the string follows the rules of a title
22. isupper() Returns True if all characters in the string are upper case
23. join()         Joins the elements of an iterable to the end of the string
24. ljust()  Returns a left justified version of the string
25. lower()         Converts a string into lower case
26. lstrip() Returns a left trim version of the string
27. maketrans() Returns a translation table to be used in translations
28. partition() Returns a tuple where the string is parted into three parts
29. replace() Returns a string where a specified value is replaced with a specified value
30. rfind()         Searches the string for a specified value and returns the last position of where it was found
31. rindex() Searches the string for a specified value and returns the last position of where it was found
32. rjust()         Returns a right justified version of the string
33. rpartition() Returns a tuple where the string is parted into three parts
34. rsplit() Splits the string at the specified separator, and returns a list
35. rstrip() Returns a right trim version of the string
36. split()         Splits the string at the specified separator, and returns a list
37. splitlines() Splits the string at line breaks and returns a list
38. startswith() Returns true if the string starts with the specified value
39. strip()         Returns a trimmed version of the string
40. swapcase() Swaps cases, lower case becomes upper case and vice versa
41. title()         Converts the first character of each word to upper case
42. translate() Returns a translated string
43. upper()         Converts a string into upper case
44. zfill()         Fills the string with a specified number of 0 values at the beginning

my-courses.net

#### Exercise 22

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].

## Friday, April 16, 2021

#### Exercise 12

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.

#### Solution

``````def minMax(L):
# sorting the liste
L.sort()

return (L , L[-1])

# Exemple
L = [41, 19 , 5 , 21 ,7 , 11]

print(minMax(L)) # the out put is:  (5, 41)``````

Younes Derfoufi
my-courses.net

#### Exercise 11

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 10

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 return -1 if element x is not in the list.

## Thursday, April 15, 2021

#### Exercise9

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.

#### Solution

``````def examineList (L, a):
if a in L:
return True
else: return False
# Example
L = [13, 9, 5, 23]
a = 5
print (examineList (L, a)) # the output is: True``````

Younes Derfoufi
my-courses.net

#### Exercise8

Write an algorithm in python that returns the average of the terms in a list of numbers.

#### Solution

``````def averageList (L):
# initialization of the average
m = 0
for x in L:
m = m + x
# average = sum of the elements of L / length of L
m = m / len(L)
return m

# Example
L = [3, 7, 8, 2]
print ("the average is: m =", averageList (L))
# the output is: the average is: m = 5.0``````

Younes Derfoufi
my-courses.net

## Saturday, April 3, 2021

#### Source code

``````import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton ,  QGridLayout

def window():
app = QApplication(sys.argv)
win = QWidget()

grid = QGridLayout()

grid.addWidget(QPushButton("Button 1") , 0 , 0)
grid.addWidget(QPushButton("Button 2") , 1 , 0)
grid.addWidget(QPushButton("Button 3") , 0 , 1)
grid.addWidget(QPushButton("Button 4") , 1 , 1)
grid.addWidget(QPushButton("Button 5") , 0 , 2)
grid.addWidget(QPushButton("Button 6") , 1 , 2)
grid.addWidget(QPushButton("Button 7") , 2 , 0)
grid.addWidget(QPushButton("Button 8") , 2 , 1)
grid.addWidget(QPushButton("Button 9") , 2 , 2)

win.setLayout(grid)

win.setWindowTitle("PyQt Grid Layout")
win.setGeometry(50,50,400,200)
win.show()
sys.exit(app.exec_())

if __name__ == '__main__':
window()``````

Younes Derfoufi
my-courses.net

## Thursday, April 1, 2021

``````import sys
from PyQt5.QtWidgets import QApplication, QWidget, QLineEdit

def onChangeText():
Text = fieldEdit.text()
print(Text)

app = QApplication(sys.argv)

widget = QWidget()

fieldEdit = QLineEdit(widget)
fieldEdit.move(70 , 20)
fieldEdit.resize(200 , 30)
fieldEdit.textChanged.connect(onChangeText)

widget.setGeometry(100,100,400,200)
widget.setWindowTitle("QLineEdit Input Text Field !")
widget.show()

sys.exit(app.exec_())``````

Younes Derfoufi
my-courses.net

## Monday, March 29, 2021

``````import sys

from PyQt5.QtWidgets import QApplication, QWidget, QPushButton

def buttonAction():
print("You clicked on the button !")

app = QApplication(sys.argv)
widget = QWidget()

myButton = QPushButton(widget)
myButton.move(50 , 30)
myButton.clicked.connect(buttonAction)

widget.setGeometry(100, 100 , 320 , 200)
widget.setWindowTitle("Example of PyQt5 Button")
widget.show()
sys.exit(app.exec_())``````

Younes Derfoufi
my-courses.net
``````import sys

from PyQt5.QtWidgets import QApplication, QWidget, QLabel

def window():
app = QApplication(sys.argv) # create a pyqt5 app
widget = QWidget() # create Window within the app

textLabel = QLabel(widget)  # create a label within the widget
textLabel.setText("Hello  World   From   PyQt5 !") # adding a text to the label
textLabel.move(120,80)  # label dimensions

widget.setGeometry(100,100,400,200) # window dimensions
widget.setWindowTitle("First PyQt5") # window title
widget.show()
sys.exit(app.exec_())

if __name__ == '__main__':
window()``````

Younes Derfoufi
my-courses.net

## Sunday, February 28, 2021

Twitter has announced plans for a brand new "first rate comply with" function for you to permit account holders to fee for exceptional additional content material.
this can take the shape of extra tweets, joining a network group or receiving a newsletter, the firm said.
it is the first time in a while that the platform has announced huge adjustments to the way wherein people can use it.

## Friday, February 26, 2021 #### 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]

## 1. Creating a Label Widget

We have already seen how to create a label in the previous tutorial by importing the Label class:
``from kivy.uix.label import Label``

#### code to display a 'Hello World!' label

``````from kivy.app import App
from kivy.uix.label import Label
class myApp(App):
def build(self):
lbl=Label(text='Hello World!')
return lbl
myApp().run()``````

## Python Exercises With Solutions

1. Python Arithmetic Exercises
2. Equations & System Of Equations
3. Polynomials and Functions
4. Python Arithmetic Exercises
5. Numpy, Matplolib, Sympy , Scipy - Exercises
6. Python Arithmetic Exercises

Younes Derfoufi

## Sample Text 