teaching:progappchim:codes_presentation

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
teaching:progappchim:codes_presentation [2015/02/17 17:47] villersdteaching:progappchim:codes_presentation [2021/01/28 17:58] (Version actuelle) villersd
Ligne 4: Ligne 4:
 //Cf.// la [[https://docs.python.org/2/library/turtle.html|documentation officielle]]. //Cf.// la [[https://docs.python.org/2/library/turtle.html|documentation officielle]].
  
-<sxh python; title : turtle-01.py>+<code python turtle-01.py>
 #!/usr/bin/python #!/usr/bin/python
 # -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
Ligne 38: Ligne 38:
  
 time.sleep(10) time.sleep(10)
-</sxh>+</code>
  
 ===== Tkinter ===== ===== Tkinter =====
-En Python 2. Pour Python 3, utiliser "from tkinter import *" et print() ! 
  
 //Cf.// la [[https://docs.python.org/2/library/tk.html|documentation officielle]]. //Cf.// la [[https://docs.python.org/2/library/tk.html|documentation officielle]].
  
-<sxh python; title : tkinter-simple-entry.py>+<code python tkinter-simple-entry.py>
 #!/usr/bin/python #!/usr/bin/python
 # -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
Ligne 51: Ligne 50:
 # lecture de 2 masses par une fenêtre tk # lecture de 2 masses par une fenêtre tk
  
-from Tkinter import *+from tkinter import *
  
 fen01 = Tk() fen01 = Tk()
Ligne 72: Ligne 71:
 fen01.destroy() fen01.destroy()
  
-print 'Masses lues : ', m1,' et ',m2+print('Masses lues : ', m1,' et ',m2)
  
-</sxh>+</code>
  
 ==== Canvas Tkinter : rebond d'une balle ==== ==== Canvas Tkinter : rebond d'une balle ====
    
-<sxh python; title : anima_auto_rebond.py>+<code python anima_auto_rebond.py>
 #! /usr/bin/env python #! /usr/bin/env python
 # -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
Ligne 84: Ligne 83:
 # Petit exercice utilisant la librairie graphique Tkinter # Petit exercice utilisant la librairie graphique Tkinter
  
-from Tkinter import *+from tkinter import *
  
 # définition des gestionnaires # définition des gestionnaires
Ligne 137: Ligne 136:
 fen1.mainloop() fen1.mainloop()
 fen1.destroy() fen1.destroy()
-</sxh>+</code> 
 + 
 +==== DemoTkinter ==== 
 +  * télécharger ici : [[http://pythonfacile.free.fr/python/demotkinter.html]] 
 + 
 +===== Matplotlib - pylab ===== 
 + 
 +<code python simple_fonction.py> 
 +#!/usr/bin/python 
 +# -*- coding: utf-8 -*- 
 +# cosinusoïde amortie 
 + 
 +from pylab import * 
 + 
 +def my_func(t):         
 +    s1 = cos(2*pi*t)         
 +    e1 = exp(-t)         
 +    return s1*e1 
 + 
 +tvals = arange(0., 5., 0.05) 
 +#plot(tvals, my_func(tvals)) 
 + 
 +#show() 
 + 
 +plot(tvals, my_func(tvals), 'bo', tvals, my_func(tvals), 'k'
 + 
 +show() 
 +</code>
  
  
  • teaching/progappchim/codes_presentation.txt
  • Dernière modification : 2021/01/28 17:58
  • de villersd