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 19:58] – [calculatrice python3 menu texte] gerardadmin | debuter_en_python [2023/02/02 16:51] – [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 94: | Ligne 98: | ||
* [[https:// | * [[https:// | ||
- | === Doc Tuto - Livre === | + | === Doc Tuto - Livre === |
- | + | * {{ :apprendre_a_coder_grace_a_minecraft_ed1_v1-ch5.pdf | Minecraft :Interagir avec les circuits électroniques Ch5}} | |
- | + | * -3- [[ http:// | |
- | | + | * -4- [[https:// |
- | | + | * -5- [[https:// |
- | | + | |
- | | + | |
- | | + | |
===== Les programmes du Tuto en Python | ===== Les programmes du Tuto en Python | ||
Ligne 125: | Ligne 126: | ||
===== 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 == | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | [[https:// | ||
<code python py menu001.py> | <code python py menu001.py> | ||
# Import the necessary packages | # Import the necessary packages | ||
# pip install console-menu | # pip install console-menu | ||
+ | # Modifier par GL le 15/01/2022 | ||
############################# | ############################# | ||
Ligne 172: | Ligne 223: | ||
<code python py calc3.py> | <code python py calc3.py> | ||
## Programme de calculatrice tres simple pour demarrer en python | ## Programme de calculatrice tres simple pour demarrer en python | ||
- | ## GL 01/ | + | ## Modifier par GL 01/ |
############# | ############# | ||
Ligne 420: | Ligne 471: | ||
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/09/11 08:15 de gerardadmin