ferro.py

Created by bhenry1

Created on November 11, 2023

671 Bytes


def volume(x):
  cote = 140-2*x
  return cote*cote*x
  
def table() :
  for x in range(0, 72, 10):
    print (x, volume(x))
    
a = 23.3332    # x minimal
b = 23.3336    # x maximal
pas = (b - a) / 100  # pas entre 2 valeurs de x
x = a     # première valeur de x qui évoluera
x_max = x # antécédent provisoire du max
v_max = volume(x) # volume max provisoire
for compt in range(100) :# répéter 100 fois
    x = x + pas      # x suivant
    v_x = volume(x)  # volume pour x
    if v_x > v_max : # si ... 
        x_max = x    # change antécédent du max
        v_max = v_x   # change volume max
print (round(pas,6), round(x_max,6), v_max) # affichage