longueur_cf.py

Created by cent20

Created on October 14, 2019

399 Bytes

2nde TDG 04
Exercice 5


from math import sqrt

def f(x):
    return .........  # ecrire une f° ici

def dist(x1,y1,x2,y2):
    return sqrt((x1-x2)**2 + (y1-y2)**2)

def longueur(a,b,n):
    long = ...     # ecrire une valeur ici
    x1,y1 = a,f(a)
    h = (b-a)/n
    for i in range(n):
        x2 = x1 + h
        y2 = f(x2)
        long = long + dist(x1,y1,x2,y2)
        x1,y1 = x2,y2
    return long