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
Branches
Tags
No related merge requests found
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
Quelle fonction voulez-vous que je crée ? Quelle fonction voulez-vous que je crée ?
<br> <br>
<textarea rows = "5" cols = "60" name = "description"> <textarea rows = "5" cols = "60" name = "description">
A function to solve a quadratic equation Résolution d'une équation du second degré
</textarea><br> </textarea><br>
Avec combien de tests ? Avec combien de tests ?
<input type="number" id="test_quantity" name="test_quantity" value="5" min="1" max="5"> <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 ...@@ -19,32 +19,17 @@ A function to solve a quadratic equation
<h2>Programme en langage Python</h2> <h2>Programme en langage Python</h2>
<form action=""> <form action="">
<textarea name="program" id="program" cols="70" rows="20"> <textarea name="program" id="program" cols="70" rows="20">
def quadratic_equation(a, b, c): #Fonction qui calcule les solutions d'une équation du second degré
""" def equation_second_degre(a,b,c):
Solves a quadratic equation of the form ax^2 + bx + c = 0 delta = b**2 - 4*a*c
Parameters if delta < 0:
---------- return None
a : float elif delta == 0:
Coefficient of x^2 return -b/(2*a)
b : float else:
Coefficient of x x1 = (-b + delta**0.5)/(2*a)
c : float x2 = (-b - delta**0.5)/(2*a)
Constant term return x1,x2
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
</textarea><br> </textarea><br>
<input type="submit" value="Compile et teste !" /> <input type="submit" value="Compile et teste !" />
...@@ -55,26 +40,20 @@ def quadratic_equation(a, b, c): ...@@ -55,26 +40,20 @@ def quadratic_equation(a, b, c):
<h2>Voici cinq tests unitaires</h2> <h2>Voici cinq tests unitaires</h2>
<form action=""> <form action="">
<textarea name="tests" id="tests" cols="70" rows="20"> <textarea name="tests" id="tests" cols="70" rows="20">
import unittest #Test unitaire 1
assert equation_second_degre(1,2,1) == (-1.0,)
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))
def test_quadratic_equation_3(self): #Test unitaire 2
self.assertEqual(quadratic_equation(1, -2, -3), (3+0j, -1+0j)) assert equation_second_degre(1,2,-3) == (1.0, -3.0)
def test_quadratic_equation_4(self): #Test unitaire 3
self.assertEqual(quadratic_equation(1, -4, 4), (2+0j, 2+0j)) assert equation_second_degre(1,0,1) == None
def test_quadratic_equation_5(self): #Test unitaire 4
self.assertEqual(quadratic_equation(2, -7, 3), (3+0j, 0.5+0j)) assert equation_second_degre(1,-4,4) == (2.0,)
if __name__ == '__main__': #Test unitaire 5
unittest.main() assert equation_second_degre(2,3,1) == (-0.5, -1.0)
</textarea><br> </textarea><br>
<input type="submit" value="Teste à nouveau !" /> <input type="submit" value="Teste à nouveau !" />
</form> </form>
......
...@@ -12,6 +12,8 @@ Langage de développement : au choix ...@@ -12,6 +12,8 @@ Langage de développement : au choix
Framework Web : au choix Framework Web : au choix
Dépôt GIT : https://gitlab.univ-lorraine.fr 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 ## Langages cibles
**Groupe 1** : Python / Prolog **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