64 lines
681 B
Python
64 lines
681 B
Python
from sympy import symbols, Eq, solve
|
|
|
|
x = [1,2,4,5]
|
|
y = [3,4,6,7]
|
|
|
|
x0 = [1,1,1,1]
|
|
x1 = x[:]
|
|
x2 = []
|
|
xy = []
|
|
|
|
for number in x:
|
|
x2.append(number*number)
|
|
|
|
x0y = y[:]
|
|
|
|
for i in range(0,len(x)):
|
|
xy.append(x1[i] * x0y[i])
|
|
|
|
s0 = 0
|
|
|
|
for x in x0:
|
|
s0=s0+x
|
|
|
|
s1 = 0
|
|
|
|
for x in x1:
|
|
s1=s1+x
|
|
|
|
s2 = 0
|
|
|
|
for x in x2:
|
|
s2=s2+x
|
|
|
|
t0 = 0
|
|
|
|
for x in x0y:
|
|
t0=t0+x
|
|
|
|
t1 = 0
|
|
|
|
for x in xy:
|
|
t1=t1+x
|
|
|
|
print(f"{s0} {s1} {s2} {t0} {t1}")
|
|
|
|
# Definiujemy zmienne
|
|
a0, a1 = symbols('a0 a1')
|
|
|
|
# Tworzymy równania
|
|
eq1 = Eq(4 * a0 + 12 * a1, 20)
|
|
eq2 = Eq(12 * a0 + 46 * a1, 70)
|
|
|
|
# Rozwiązujemy układ równań
|
|
solution = solve((eq1, eq2), (a0, a1))
|
|
|
|
# Wyświetlamy wynik
|
|
print(solution)
|
|
|
|
|
|
|
|
|
|
|
|
|