[apps/code] Put back the polynomial script

This commit is contained in:
Léa Saviot
2020-03-30 17:21:47 +02:00
committed by Émilie Feral
parent b2c95bcbbf
commit 2ac1396dd2

View File

@@ -40,13 +40,18 @@ def mandelbrot(N_iteration):
# Draw a pixel colored in 'col' at position (x,y)
kandinsky.set_pixel(x,y,col))");
constexpr ScriptTemplate polynomialScriptTemplate("polynomial.py", "\x01" R"(from pyplot import *
x = [1,2,3,4]
y = [-1,-2,-3,-4]
scatter(x, y)
plot(y, x)
text(-1,-1,"Coucou")
show())");
constexpr ScriptTemplate polynomialScriptTemplate("polynomial.py", "\x01" R"(from math import *
# roots(a,b,c) computes the solutions of the equation a*x**2+b*x+c=0
def roots(a,b,c):
delta = b*b-4*a*c
if delta == 0:
return -b/(2*a)
elif delta > 0:
x_1 = (-b-sqrt(delta))/(2*a)
x_2 = (-b+sqrt(delta))/(2*a)
return x_1, x_2
else:
return None)");
constexpr ScriptTemplate parabolaScriptTemplate("parabola.py", "\x01" R"(from matplotlib.pyplot import *
from math import *