Solution Exercise 11: algorithm python that find the divisors of an integer in python
Exercise 11 Write a program in Python that asks the user to enter an integer n and displays all the divisors of this number.
Cours Python
Exercise 11 Write a program in Python that asks the user to enter an integer n and displays all the divisors of this number.
Contenu du cours A propos de l'extension Woocommerce Pourquoi choisir WooCommerce ? Liste des extensions liées à woocommerce Les différentes méthode de payement sur woocommerce Inconvénients de Woocommerce Conclusion 1. A propos de l'extension Woocommerce WooCommerce est un plugin (extension) du système WordPress open source destinée principalement au commerce électronique. WooCommerce a été crée par…
Exercise 9. Write a program in Python that asks the user to enter an integer n and display n! Solution
Contenu du cours Qu'est-ce que l'hébergement VPS (virtual private server)? Comment fonctionne un hébergement VPS ? Comparaison d'un VPS avec d'autres types d'hébergement Avantages et inconvénients du serveur privé virtuel VPS Quand utiliser et comment décider qu'il est temps de passer à un VPS? Comment choisir le meilleur plan d'hébergement VPS pour votre site Web…
Exercise 8 Write a python algorithm that asks the user to enter an integer n and displays the value of the sum 1 + 2 + … + n = ?
Exercise 7 Write a Python algorithm that asks the user to enter 3 numbers x, y and z and display their maximum without using any predefined function.
Contenu du cours La balise d'insertion d'images <img> Les attributs de la balise <img> Exemples d'usage des attributs de la balise IMG 3.1 Les attributs width et height 3.2 L'attribut align 3.3 L'attribut border 3.4 L'attribut alt 3.5 L'attribut vspace 1. La balise d'insertion d'images <img> Afin d'embellir nos pages web, nous devons impérativement utiliser…
Exercise 12 By using the sort() method, write an algorithm in python as a function which takes a list L of numbers as a parameter and which returns the tuple (min , max) formed from the minimum and the maximum of the list.
Exercise 12 . 1) – Write a program in Python that asks the user to enter an integer n and display him the multiplication table of this number. 2) – Improve the program so that it displays the multiplication tables of all the numbers between 1 and 9
Exercise 11 Write an algorithm in python as a function which takes as parameters 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 = [13, 11, 7, 25] and n =…
Exercise 10 Write an algorithm in python as a function which takes as a parameter a tuple (L, a) formed by a list L and an element 'a' and which returns the position of the element 'a' in the list L. The function must return -1 if the element 'a' is not in the list.
Exercise 9 Write an algorithm in python as a function which takes as a 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 nope. Solution
|
1 2 3 4 5 6 7 8 9 10 11 12 |
def examinList(L, a): if a in L: return True else: return False # Example L = [13, 9, 17, 23] a = 17 b = 55 print(examinList(L,a)) # The output is: True print(examinList(L,b)) # The output is: False |
Younes Derfoufi CRMEF OUJDA
Exercise 8 Write an algorithm in python that returns the average of the terms of a list of numbers.
Exercise 7 Write a Python program that returns the list of divisors of a given integer. Example if n = 36 , the algorithm returns the list [1, 2, 3, 6, 9, 18 , 36]
Contenu du cours Qu'est-ce qu'une fonction en Python? Fonction définit par l'utilisateur Fonctions intégrées en Python Fonction lumbda Quiz 1. Qu'est-ce qu'une fonction en Python? En Python, une fonction est un groupe d'instructions liées et structurées dont le but d'effectuer une tâche spécifique lors qu'elle est appelée. Une fonction est utilisée pour appeler un…
Contenu du cours A propos de la balise BODY Compatibilité Attributs spécifiques de la balise BODY 1. A propos de la balise BODY La balise <body> est une balise principale qui définit tout le corps de la page web. L'élément <body> englobe la totalité du contenu d'un document HTML, comme: texte, images, hyperliens, etc.
Exercise 16 Write a python program to display all characters of a string variable. Example for s = "Python", the program displays the characters: P y t h o n Solution (First method)
|
1 2 3 4 5 6 7 8 9 |
# Ask the user to enter a string variable s s = input("Enter a string of characters s: ") # get the length of s n = len(s) # display all characters of s for i in range(0, n): print(s[i]) |
Solution (second method)
|
1 2 3 4 5 6 |
# Ask the user to enter a string variable s s = input("Type a string of characters s: ") # display all characters of s for x in s: print(x) |
Younes Derfoufi CRMEF OUJDA