Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def linear(a, b, c):
- if a == 0:
- if b == c:
- print("x - любое число")
- else:
- print("делить на ноль нельзя! решений нет")
- else:
- print((c-b)/a)
- def squarer(a,b,c):
- if a == 0:
- linear(a,b,c)
- return
- D = b**2 - 4*a*c
- if D > 0:
- print("x1 =", (-b+D**(0.5))/(2*a))
- print("x2 =", (-b - D ** (0.5)) / (2 * a))
- elif D == 0:
- print(-b/(2*a))
- else:
- print("корней нет")
- def four_ex(a,b,c):
- if a == 0:
- squarer(b,0,c)
- return
- D = b**2 - 4*a*c
- if D > 0:
- x1 = (-b+D**(0.5))/(2*a)
- x2 = (-b - D ** (0.5)) / (2 * a)
- if x1 >= 0:
- print("x1 =", x1**0.5)
- else:
- print("x1 не существует")
- if x2 >= 0:
- print("x2=", x2**0.5)
- else:
- print("x2 не существует")
- elif D == 0:
- x = -b/(2*a)
- if x >= 0:
- print(x)
- else:
- print("x не существует")
- else:
- print("корней нет")
- print("Какой вид уравнений хотите решить? 1)ax+b=c ; 2)ax^2+bx+c=0; 3)ax^4+bx^2+c=0")
- choice = input("Номер вида уравнения:")
- if choice == "1":
- print("Решаем уравнение вида ax+b=c. Введите коефициенты:")
- a = int(input("a="))
- b = int(input("b="))
- c = int(input("c="))
- linear(a,b,c)
- elif choice == "2":
- print("Решаем уравнение вида ax^2+bx+c = 0. Введите коефициенты:")
- a = int(input("a="))
- b = int(input("b="))
- c = int(input("c="))
- squarer(a,b,c)
- elif choice == "3":
- print("Решаем уравнение вида ax^4+bx^2+c = 0. Введите коефициенты:")
- a = int(input("a="))
- b = int(input("b="))
- c = int(input("c="))
- four_ex(a,b,c)
- else:
- print("Такого типа нет")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement