import matplotlib.pyplot as plt
import numpy as np
import math
import decimal
z=0
l=str(input("Вырерите язык en/ru | Choose language en/ru : "))
def yr():
if l=='ru':
print("Введите коэффициенты для квадратного уравнения (ax^2 + bx + c = 0):")
elif l=='en':
print("Enter coefficients for quadratic equation (ax^2 + bx + c = 0):")
a = float(input("a = "))
b = float(input("b = "))
c = float(input("c = "))
discr = b ** 2 - 4 * a * c
if l=='ru':
print("Дискриминант D = %.2f" % discr)
elif l=='en':
print("Discriminant D = %.2f" % discr)
if discr > 0:
x1 = (-b + math.sqrt(discr)) / (2 * a)
x2 = (-b - math.sqrt(discr)) / (2 * a)
print("x1 = %.2f \nx2 = %.2f" % (x1, x2))
elif discr == 0:
x = -b / (2 * a)
print("x = %.2f" % x)
else:
if l=='ru':
print("Корней нет")
elif l=='en':
print("No roots")
def funct_x3():
X = np.linspace(-10,10,21)
Y = X**3
ax = plt.gca()
ax.spines['left'].set_position('center')
ax.spines['bottom'].set_position('center')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
if l=='ru':
plt.title(r'График функции $y = x ^3 $', fontsize=16, y =1.05);
elif l=='en':
plt.title(r'Function graph $y = x ^3 $', fontsize=16, y =1.05);
plt.plot(X, Y , color='green',linestyle='-', label= '')
plt.show()
def funct_kxdel():
dx = 0.1
X = np.around(np.arange(-10,10,dx),decimals=4)
Y = 1/X
ax = plt.gca()
ax.spines['left'].set_position('center')
ax.spines['bottom'].set_position('center')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
if l=='ru':
plt.title(r'График функции $y = k/x $', fontsize=16, y =1.05);
elif l=='ru':
plt.title(r'Function graph $y = k/x $', fontsize=16, y =1.05);
plt.plot(X, Y , color='blue',marker='',linestyle='-', label= '')
plt.show()
def funct_kx():
X = np.linspace(-10,10,21)
Y = 1*X
ax = plt.gca()
ax.spines['left'].set_position('center')
ax.spines['bottom'].set_position('center')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
plt.title(r'График функции $y = kx $', fontsize=16, y =1.05);
plt.plot(X, Y , color='red',marker='',linestyle='-', label= '')
plt.show()
def funct_x2():
X = np.linspace(-10,10,21)
Y = X**2
ax = plt.gca()
ax.spines['left'].set_position('center')
ax.spines['bottom']#.set_position('center')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
plt.title(r'График функции $y = x ^2 $', fontsize=16, y =1.05);
plt.plot(X, Y , color='orange',marker='',linestyle='-', label= '')
plt.show()
if l=='ru' and z==0:
print("Какую операцию вы хотели бы выполнить? Введите : \n1 - Решить квадратное уравнение;\n2 - Построить график функции y=x^3;\n3 - Построить график функции y = k/x;\n4 - Построить график функции y = kx; \n5 - Построить график функции y = x^2;\n")
z = int(input("Ввод : "))
elif l =='en' and z==0:
print("What operation would you like to perform? Enter: \n1 - Solve a quadratic equation; \n2 - Build a graph of the function y = x ^ 3; \n3 - Build a graph of the function y = k / x; \n4 - Build a graph of the function y = kx ; \n5 - Build a graph of the function y = x ^ 2; \n ")
z = int(input("Enter : "))
if z==1:
yr()
v=str(input("Вы хотите продолжить y-yes/n-no :"))
if v == 'y':
z=0
elif z==2:
funct_x3()
elif z==3:
funct_kxdel()
elif z==4:
funct_kx()
elif z==5:
funct_x2()