Spaces:
Sleeping
Sleeping
| function_code,test_code | |
| "def calculate_discount(price, discount_percent): | |
| if discount_percent < 0 or discount_percent > 100: | |
| raise ValueError('Discount must be between 0 and 100') | |
| discount = price * discount_percent / 100 | |
| return round(price - discount, 2)","import unittest | |
| from target import calculate_discount | |
| class TestCalculateDiscount(unittest.TestCase): | |
| def test_basic(self): | |
| self.assertEqual(calculate_discount(100, 10), 90.0) | |
| " | |
| "def count_words(text): | |
| if not text or not text.strip(): | |
| return 0 | |
| return len(text.strip().split())","import unittest | |
| from target import count_words | |
| class TestCountWords(unittest.TestCase): | |
| def test_basic(self): | |
| self.assertEqual(count_words('hello world'), 2) | |
| " | |