debuter_en_python
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédenteProchaine révisionLes deux révisions suivantes | ||
debuter_en_python [2022/01/15 20:02] – [Menu en mode texte python3] gerardadmin | debuter_en_python [2023/09/29 22:24] – [Doc Tuto - Livre] gerardadmin | ||
---|---|---|---|
Ligne 31: | Ligne 31: | ||
======== Le Python ======== | ======== Le Python ======== | ||
- | [[https://www.python.org/downloads/|Telecharger python]] | + | < |
+ | |||
+ | [Apprendre python 3 en ligne](https://pythontutor.com/) | ||
+ | |||
+ | </markdown> | ||
[[https:// | [[https:// | ||
Ligne 37: | Ligne 41: | ||
[[https:// | [[https:// | ||
+ | [[http:// | ||
[[https:// | [[https:// | ||
Ligne 94: | Ligne 99: | ||
* [[https:// | * [[https:// | ||
- | === Doc Tuto - Livre === | + | === Doc Tuto - Livre === |
+ | * {{ : | ||
+ | * [[ https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
- | |||
- | * -1- [[http:// | ||
- | * -2- [[http:// | ||
- | * -3- [[ http:// | ||
- | * -4- [[https:// | ||
- | * -5- [[https:// | ||
- | |||
- | ===== Les programmes du Tuto en Python | ||
- | |||
- | * [[http:// | ||
===== Videos ===== | ===== Videos ===== | ||
Ligne 125: | Ligne 125: | ||
===== Programmes d' | ===== Programmes d' | ||
+ | |||
+ | == Menu 1 en mode texte tres simple Python3 == | ||
+ | |||
+ | <code python py menu002.py> | ||
+ | menu_options = { | ||
+ | 1: ' | ||
+ | 2: ' | ||
+ | 3: ' | ||
+ | 4: ' | ||
+ | } | ||
+ | |||
+ | def print_menu(): | ||
+ | for key in menu_options.keys(): | ||
+ | print (key, ' | ||
+ | |||
+ | def option1(): | ||
+ | | ||
+ | |||
+ | def option2(): | ||
+ | | ||
+ | |||
+ | def option3(): | ||
+ | | ||
+ | |||
+ | if __name__==' | ||
+ | while(True): | ||
+ | print_menu() | ||
+ | option = '' | ||
+ | try: | ||
+ | option = int(input(' | ||
+ | except: | ||
+ | print(' | ||
+ | #Check what choice was entered and act accordingly | ||
+ | if option == 1: | ||
+ | | ||
+ | elif option == 2: | ||
+ | option2() | ||
+ | elif option == 3: | ||
+ | option3() | ||
+ | elif option == 4: | ||
+ | print(' | ||
+ | exit() | ||
+ | else: | ||
+ | print(' | ||
+ | </ | ||
== Menu en mode texte python3 == | == Menu en mode texte python3 == | ||
Ligne 425: | Ligne 470: | ||
fen.mainloop() # Gestion de la fenêtre | fen.mainloop() # Gestion de la fenêtre | ||
+ | </ | ||
+ | |||
+ | |||
+ | == lire un fichier texte == | ||
+ | |||
+ | <code python py testfich001.py> | ||
+ | #! / | ||
+ | # coding: utf-8 | ||
+ | |||
+ | menu_options = { | ||
+ | 1: ' | ||
+ | 2: ' | ||
+ | 3: 'Aide -- 3', | ||
+ | 4: ' | ||
+ | } | ||
+ | |||
+ | def print_menu(): | ||
+ | for key in menu_options.keys(): | ||
+ | print (key, ' | ||
+ | |||
+ | def option1(): | ||
+ | | ||
+ | |||
+ | def option2(): | ||
+ | | ||
+ | |||
+ | def option3(): | ||
+ | f = open(' | ||
+ | data = f.read() | ||
+ | f.close | ||
+ | print(data) | ||
+ | |||
+ | if __name__==' | ||
+ | while(True): | ||
+ | print_menu() | ||
+ | option = '' | ||
+ | try: | ||
+ | option = int(input(' | ||
+ | except: | ||
+ | print(' | ||
+ | #Check what choice was entered and act accordingly | ||
+ | if option == 1: | ||
+ | | ||
+ | elif option == 2: | ||
+ | option2() | ||
+ | elif option == 3: | ||
+ | option3() | ||
+ | elif option == 4: | ||
+ | print(' | ||
+ | exit() | ||
+ | else: | ||
+ | print(' | ||
+ | |||
+ | </ | ||
+ | |||
+ | **Inserer le fichier texte " | ||
+ | |||
+ | <code txt aide001.txt> | ||
+ | Ceci est un fichier d aide à completer suivant les besoins : | ||
+ | |||
+ | une introduction | ||
+ | |||
+ | Python (prononcé /pi.tɔ̃/) est un langage de programmation interprété, | ||
+ | |||
+ | Il favorise la programmation impérative structurée, | ||
+ | |||
+ | Il est doté d'un typage dynamique fort, d'une gestion automatique de la mémoire par ramasse-miettes et d'un système de gestion d' | ||
+ | |||
+ | il est ainsi similaire à Perl, Ruby, Scheme, Smalltalk et Tcl. | ||
+ | |||
+ | Le langage Python est placé sous une licence libre proche de la licence BSD3 et fonctionne sur la plupart des plates-formes informatiques, | ||
+ | de Windows à Unix avec notamment GNU/Linux en passant par macOS, | ||
+ | des programmeurs en offrant des outils de haut niveau et une syntaxe simple à utiliser. | ||
+ | |||
+ | Il est également apprécié par certains pédagogues qui y trouvent un langage où la syntaxe, clairement séparée des mécanismes de bas niveau, permet une initiation aisée aux concepts de base de la programmation5. | ||
</ | </ | ||
/home/chanteri/www/fablab37110/data/pages/debuter_en_python.txt · Dernière modification : 2024/07/18 13:37 de gerardadmin