Skip to content

exo1 #234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

exo1 #234

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions exo1/exo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,16 @@
Write the code for this class, with the appropriate constructor.
Example of code using the class: i = Item(10, 20)
"""
class Item:
def __init__(self,weight,price):
self.weight=weight
self.price=price

def get_price(self):
print('price:',self.price)
def get_weight(self):
print('weight:',self.weight)

i=Item(10,20)

i.get_price()
32 changes: 32 additions & 0 deletions exo2/exo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,35 @@
( "spam", "eggs" )
)
"""
import unittest

class TestSolution(unittest.TestCase):

def test_fixed_tests_true(self):
fixed_tests_True = [
("samurai", "ai"),
("ninja", "ja"),
("sensei", "i"),
("abc", "abc"),
("abcabc", "bc"),
("fails", "ails")
]
for string, ending in fixed_tests_True:
with self.subTest(string=string, ending=ending):
self.assertTrue(solution(string, ending))

def test_fixed_tests_false(self):
fixed_tests_False = [
("sumo", "omo"),
("samurai", "ra"),
("abc", "abcd"),
("ails", "fails"),
("this", "fails"),
("spam", "eggs")
]
for string, ending in fixed_tests_False:
with self.subTest(string=string, ending=ending):
self.assertFalse(solution(string, ending))

if _name_ == '_main_':
unittest.main()
18 changes: 16 additions & 2 deletions exo3/exo3.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,19 @@


def processLines(lines) -> str:
# Implementer votre réponse ici
return "OK"
# Lecture des données d'entrée
N = int(lines[0]) # Nombre de sprints
T = int(lines[1]) # Nombre de tâches dans le backlog initial

# Initialisation du backlog avec T tâches
backlog = T

# Boucle sur les N sprints pour mettre à jour le backlog
for i in range(2, 2 + N):
V, U = map(int, lines[i].split()) # V est le nombre de tâches validées, U est la variation du backlog
backlog -= V # Retirer les tâches validées
backlog += U # Ajuster avec les tâches ajoutées ou supprimées

# Si le backlog est vide, on retourne "OK", sinon "KO"
return "OK" if backlog == 0 else "KO"