Advertisement
Eryk_Czarny

OlaV2.0

Mar 20th, 2023
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. def main():
  2.     kalkulator()
  3.  
  4.  
  5. def pobranie_danych():
  6.     try:
  7.         a = float(input("Podaj a: "))
  8.         b = float(input("Podaj b: "))
  9.         c = float(input("Podaj c: "))
  10.         return a, b, c
  11.     except:
  12.         print("Podano zle dane")
  13.         exit()
  14.  
  15.  
  16. def kalkulator():
  17.     import math
  18.     a, b, c = pobranie_danych()
  19.     delta = (math.pow(b, 2) - (4 * a * c))
  20.     if delta > 0:
  21.         x1 = (-b - math.sqrt(delta))/(2 * a)
  22.         x2 = (-b + math.sqrt(delta)) / (2 * a)
  23.         print(f"Funkcja ma dwa rozwiazania jest to: ")
  24.         print(f"x1 = {x1}")
  25.         print(f"x2 = {x2}")
  26.     elif delta == 0:
  27.         x0 = -b / (2*a)
  28.         print(f"Funckja ma jedno miejsce zerowe jest to x0 = {x0}")
  29.     elif delta < 0:
  30.         print("Brak rozwiazan funkcji")
  31.  
  32.     else:
  33.         print("Blad")
  34.  
  35.  
  36. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement