Skip to content
Snippets Groups Projects
Commit 0f4932c3 authored by PIERRON Laurent's avatar PIERRON Laurent :man_in_tuxedo_tone1:
Browse files

adding CI/CD workflow. changing the Python example with a French one.

parent ba812bf4
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@
Quelle fonction voulez-vous que je crée ?
<br>
<textarea rows = "5" cols = "60" name = "description">
A function to solve a quadratic equation
Résolution d'une équation du second degré
</textarea><br>
Avec combien de tests ?
<input type="number" id="test_quantity" name="test_quantity" value="5" min="1" max="5">
......@@ -19,32 +19,17 @@ A function to solve a quadratic equation
<h2>Programme en langage Python</h2>
<form action="">
<textarea name="program" id="program" cols="70" rows="20">
def quadratic_equation(a, b, c):
"""
Solves a quadratic equation of the form ax^2 + bx + c = 0
Parameters
----------
a : float
Coefficient of x^2
b : float
Coefficient of x
c : float
Constant term
Returns
-------
x1 : float
First solution
x2 : float
Second solution
"""
# Compute the discriminant
discriminant = (b**2) - (4*a*c)
# Compute the two solutions
x1 = (-b + discriminant**0.5) / (2*a)
x2 = (-b - discriminant**0.5) / (2*a)
return x1, x2
#Fonction qui calcule les solutions d'une équation du second degré
def equation_second_degre(a,b,c):
delta = b**2 - 4*a*c
if delta < 0:
return None
elif delta == 0:
return -b/(2*a)
else:
x1 = (-b + delta**0.5)/(2*a)
x2 = (-b - delta**0.5)/(2*a)
return x1,x2
</textarea><br>
<input type="submit" value="Compile et teste !" />
......@@ -55,26 +40,20 @@ def quadratic_equation(a, b, c):
<h2>Voici cinq tests unitaires</h2>
<form action="">
<textarea name="tests" id="tests" cols="70" rows="20">
import unittest
class TestQuadraticEquation(unittest.TestCase):
def test_quadratic_equation_1(self):
self.assertEqual(quadratic_equation(1, 0, -4), (2+0j, -2+0j))
def test_quadratic_equation_2(self):
self.assertEqual(quadratic_equation(2, -3, 1), (1+0j, 0.5+0j))
#Test unitaire 1
assert equation_second_degre(1,2,1) == (-1.0,)
def test_quadratic_equation_3(self):
self.assertEqual(quadratic_equation(1, -2, -3), (3+0j, -1+0j))
#Test unitaire 2
assert equation_second_degre(1,2,-3) == (1.0, -3.0)
def test_quadratic_equation_4(self):
self.assertEqual(quadratic_equation(1, -4, 4), (2+0j, 2+0j))
#Test unitaire 3
assert equation_second_degre(1,0,1) == None
def test_quadratic_equation_5(self):
self.assertEqual(quadratic_equation(2, -7, 3), (3+0j, 0.5+0j))
#Test unitaire 4
assert equation_second_degre(1,-4,4) == (2.0,)
if __name__ == '__main__':
unittest.main()
#Test unitaire 5
assert equation_second_degre(2,3,1) == (-0.5, -1.0)
</textarea><br>
<input type="submit" value="Teste à nouveau !" />
</form>
......
......@@ -12,6 +12,8 @@ Langage de développement : au choix
Framework Web : au choix
Dépôt GIT : https://gitlab.univ-lorraine.fr
Peut-être qe que pour le framework, une bonne idée serait d'utiliser Laravel en partant du modèle de projet GitLab : https://gitlab.com/gitlab-org/project-templates/laravel
## Langages cibles
**Groupe 1** : Python / Prolog
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment