Advertisement
dadodasyra

TP Python

May 2nd, 2024
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.35 KB | None | 0 0
  1. def h(x):
  2.     return -4 * x ** 2 + 4 * x + 3
  3.  
  4.  
  5. def find_max_of_h():
  6.     xMax, yMax = 0, 0
  7.     x = 0
  8.     while x <= 3:
  9.         y = h(x)
  10.         if y > yMax:
  11.             yMax = y
  12.             xMax = x
  13.         x += 0.1
  14.     return xMax, yMax
  15.  
  16.  
  17. max_x, max_y = find_max_of_h()
  18. print(f"La valeur maximale de h(x) est {max_y} pour x = {max_x}")
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement