Skip to content
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

Feature/basic python #2

Merged
merged 12 commits into from
Aug 19, 2024
4 changes: 4 additions & 0 deletions .github/workflows/github-actions-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: python --version
- run: curl -sSL https://install.python-poetry.org | python3 -
# - run: cp /home/runner/work/2024/2024/Basic/Basic_Of_Python/pyproject.toml .
# - run: poetry install
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Pycharm
.idea
*.ipynb*
*.ipynb*
**__pycache__**
Empty file added Basic/Basic_Of_Python/README.md
Empty file.
2 changes: 2 additions & 0 deletions Basic/Basic_Of_Python/basic_of_python/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This allows you to import prime_numbers directly from prime_module
from .prime_numbers import prime_numbers
24 changes: 24 additions & 0 deletions Basic/Basic_Of_Python/basic_of_python/prime_numbers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""This module provides a function to check if the number is prime or not."""

def prime_numbers(x: int) -> str:
"""
Determine if a number is prime.

Args:
x (int): The number to check for primality

Returns:
str: A message stating whether the number is prime or not.

"""
for i in range(2,x//2+1):
if x%i == 0:
return f"{x} is Not Prime Number"
return f"{x} is Prime Number"



if __name__ == "__main__":
for n in [10,11]:
s = prime_numbers(n)
print(s)
740 changes: 740 additions & 0 deletions Basic/Basic_Of_Python/poetry.lock

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions Basic/Basic_Of_Python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[tool.poetry]
name = "basic-of-python"
version = "0.1.0"
description = ""
authors = ["Your Name <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.12"
pydocstyle = "^6.3.0"
sphinx = "^8.0.2"
pylint = "^3.2.6"
pytest = "^8.3.2"
pytest-cov = "^5.0.0"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Empty file.
20 changes: 20 additions & 0 deletions Basic/Basic_Of_Python/tests/prime_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest
from basic_of_python.prime_numbers import prime_numbers

def test_prime_number():
assert prime_numbers(11) == "11 is Prime Number"

def test_non_prime_number():
assert prime_numbers(10) == "10 is Not Prime Number"

def test_smallest_prime():
assert prime_numbers(2) == "2 is Prime Number"

def test_one():
assert prime_numbers(1) == "1 is Prime Number"

def test_zero():
assert prime_numbers(0) == "0 is Prime Number"

def test_negative_number():
assert prime_numbers(-5) == "-5 is Prime Number"