| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 
 |  
#!/usr/bin/python
# -*- coding: utf-8 -*-
 
import tkinter #pour le graphique
from math import * #pour les fonctions sin,cos,tan, etc
 
racine=tkinter.Tk()
 
fond=tkinter.Canvas(racine, width=500, height=500, background='darkgray')#ouvre une fenetre 500 pixels sur 500
fond.pack()#active la ligne precedente???
 
ligne=fond.create_line(0,250, 500,250, width=2)#place l'axe horizontal
ligne=fond.create_line(250,0, 250,500, width=2)#place l'axe vertical
 
#Attention : il n'y a pas d'instruction de type plot() qui permet de faire un point.
#On utilise donc le tracé d'une ligne de 1 point.
 
#fonction y=sin(x)
for x in range(-250,250) :
    k= (2*pi)/500
    y=(sin(k*x))*100
    point=fond.create_line(250+x,250-y, 251+x,251-y,fill="red", width=2)
 
#fonction y=cos(x)
for x in range(-250,250) :
    k= (2*pi)/500
    y=(cos(k*x))*100
    point=fond.create_line(250+x,250-y, 251+x,251-y,fill="green", width=2)
 
#fonction tan(x)
for x in range(-250,250) :
    k= (2*pi)/1000
    y=(tan(k*x))*100
    point=fond.create_line(250+x,250-y, 250+x,251-y,fill="purple", width=2)
 
#fonction y=ax+b   
for x in range(-250,250) :
    y=x+20
    point=fond.create_line(250+x,250-y, 251+x,251-y, fill="cyan",width=2)
 
#fonction y=x²    
for x in range(-250,250) :
    y=x**2/30
    point=fond.create_line(250+x,250-y, 251+x,251-y, fill="yellow",width=2)
 
racine.mainloop()#je ne sais pas pourquoi mettre ceci, en fait ça marche sans ca |