Skip to content

Commit

Permalink
[김필모] 12주차 미션 제출 (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
why-arong authored Jul 6, 2024
1 parent c6aab19 commit 849c02e
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions 8th_members/김필모/12주차.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@

# 나만의 Test Case 만들기

```python3
def is_prime(n):
"""
Check if a number is a prime number.
Parameters:
n (int): The number to check.
Returns:
bool: True if n is a prime number, False otherwise.
"""
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while i * i <= n:
if n % i == 0 or n % (i + 2) == 0:
return False
i += 6
return True


# Example usage:
if __name__ == "__main__":
print(is_prime(29)) # Expected output: True
print(is_prime(15)) # Expected output: False
```


```
import unittest
from src import example
class TestIsPrime(unittest.TestCase):
def test_is_prime(self):
self.assertEqual(example.is_prime(2), True)
self.assertEqual(example.is_prime(3), True)
self.assertEqual(example.is_prime(4), False)
self.assertEqual(example.is_prime(5), True)
self.assertEqual(example.is_prime(7), True)
```
<img width="592" alt="Screenshot 2024-06-30 at 5 16 31 PM" src="https://github.com/why-arong/CPython-Guide/assets/68311908/2e2c1bc8-fc02-427b-ac33-06d5f43849e2">


0 comments on commit 849c02e

Please sign in to comment.