Solution Exercise 7: Python algorithm that returns the list of divisors of a number
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]
Cours Python
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
Exercise 10 Write a python program that asks the user to enter the radius of a circle and return the area and perimeter.
Contenu du cours Les principales balises de mise en forme en HTML Tableau récapitulatifs des balises de mise en forme en html Exemples d'usages des balises de mise en forme HTML 1. Les principales balises de mise en forme en HTML Le langage HTML offre la possibilité de mettre en forme un texte en toute…
Content Définir un ensemble en Python Accès aux éléments d'un ensemble Python Longueur ou cardinal d'un ensemble Python Opérations sur un ensemble Python Récapitulatif des méthodes associées à un ensemble Python Quiz 1. Définir un ensemble en Python Un ensemble Python (Python set) est une collection modifiable d'objets distincts pouvant être hachés, comme les listes…
Exercise 4 Write a Python algorithm that asks the user to enter 5 integers of their choice and displays the list of numbers entered.
Exercise 3 Write a python algorithm as a function which takes a list l as parameters and returns a tuple of two lists (l_even, l_odd) where l_even is made up of the elements of l with an even index and l_old is made up of the elements with an odd index. Example: if: L =…
Exercise 5 Given a list L of integers, write a Python program that returns the sum of the elements of L.
Contenu du cours A propos des liens hypertextes Lien vers une adresse URL Lien vers un fichier Lien vers une boite Email Lien dans la même page 1. A propos des liens hypertextes Dans le but de facilité la navigation de page en page sur le web, le langage HTML nous offre la possibilité de…
L'encapsulation est un concept en programmation orientée objet qui consiste à regrouper les données avec les méthodes qui agissent sur ces données, ou à restreindre l'accès direct à certains composants d'un objet. C'est une technique utilisée pour cacher les détails internes d'un objet à l'extérieur et pour protéger les données d'un objet contre l'accès ou…
Exercise 6 Write a Python algorithm that asks the user to enter their age and display the message "you are major!" if the typed age is greater than or equal to 18 and the message "you are a minor!" if the typed age is less than 18
Exercise 13 Write a program program which asks the user to enter two integers 'a' and 'b' and display the quotient and the remainder of the Euclidean division of 'a' by 'b'.
Exercise 5 Write a program in Python language that asks the user to enter an integer number 'n' and display whether this number is even or odd.
Exercise 4 Write a program in Python that displays the first 100 integers
Exercise 3 Write a program in Python that asks the user to enter two numbers a and b and display their maximum, without using the max() function or any predefined function.