diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..efa407c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,162 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/latest/usage/project/#working-with-version-control +.pdm.toml +.pdm-python +.pdm-build/ + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ \ No newline at end of file diff --git a/python/api/fastapi-final/api-project-final/main.py b/python/api/fastapi-final/api-project-final/main.py new file mode 100644 index 00000000..34a1fbb4 --- /dev/null +++ b/python/api/fastapi-final/api-project-final/main.py @@ -0,0 +1,80 @@ +from fastapi import FastAPI, Header +from fastapi.responses import JSONResponse +from pydantic import BaseModel + +app = FastAPI() + + +@app.get("/sum1n/{n}") +async def read_root(n): + n = int(n) + res = 0 + for i in range(n): + res += i + return {"result": res} + + +@app.get("/fibo") +async def fibnums(n): + n = int(n) + if n <= 0: + return "Please enter the number bigger 0!" + elif n == 1: + return 0 + elif n == 2: + return 1 + else: + a, b = 0, 1 + for _ in range (2, n): + a, b = b, a + b + return JSONResponse(content={"result": b}) + + + +@app.post("/reverse") +async def revers_word(string: str = Header(...)): + return {"result": string[::-1]} + + + +element_list = [] +# Pydantic model +class ElementItem(BaseModel): + element: str + +@app.put("/list/") +async def create_item(item: ElementItem): + element_list.append(item.element) + return {"message": f"Item '{item.element}' updated successfully!"} + +@app.get("/list/") +async def get_list(): + return {"result": element_list} + + + + + +class ElementItem(BaseModel): + expr: str + +@app.post("/calculator/") +async def calc(item: ElementItem): + operands = item.expr.split(",") + num1 = float(operands[0]) + operator = operands[1] + num2 = float(operands[2]) + + match operator: + case "+": + res = num1 + num2 + case "-": + res = num1 - num2 + case "/": + if num2 == 0: + return "Division by zero is not allowed." + res = num1 / num2 + case "*": + res = num1 * num2 + + return { "result": res } \ No newline at end of file diff --git a/python/api/fastapi-final/api-project-final/requirements.txt b/python/api/fastapi-final/api-project-final/requirements.txt new file mode 100644 index 00000000..76fdf49b Binary files /dev/null and b/python/api/fastapi-final/api-project-final/requirements.txt differ diff --git a/python/api/fastapi-final/api-project-final/testapp.py b/python/api/fastapi-final/api-project-final/testapp.py new file mode 100644 index 00000000..208fc0ed --- /dev/null +++ b/python/api/fastapi-final/api-project-final/testapp.py @@ -0,0 +1,39 @@ +from fastapi.testclient import TestClient +from main import app + +client = TestClient(app) + +def test_sum1n(): + n = 5 + response = client.get(f"/sum1n/{n}") + assert response.status_code == 200 + assert response.json() == {"result": 10} + +def test_fibo(): + n = 5 + response = client.get(f"/fibo?n={n}") + assert response.status_code == 200 + assert response.json() == {"result": 3} + +def test_reverse(): + w = "hello" + response = client.post(f"/reverse", headers={"string": w}) + assert response.status_code == 200 + assert response.json() == {"result": "olleh"} + +def test_list_add(): + json_data = {"element": "Apple"} + response = client.put(f"/list", json=json_data) + assert response.status_code == 200 + assert response.json() == {"message": "Item 'Apple' updated successfully!"} + +def test_list_show(): + response = client.get(f"/list") + assert response.status_code == 200 + assert response.json() == {"result": ["Apple"]} + +def test_calculator(): + json_data = {"expr": "1,+,1"} + response = client.post(f"/calculator", json=json_data) + assert response.status_code == 200 + assert response.json() == {"result": 2.0} \ No newline at end of file diff --git a/python/api/fastapi/api-project/main.py b/python/api/fastapi/api-project/main.py new file mode 100644 index 00000000..7f5e9bb5 --- /dev/null +++ b/python/api/fastapi/api-project/main.py @@ -0,0 +1,8 @@ +from fastapi import FastAPI + +app = FastAPI() + + +@app.get("/") +def read_root(): + return {"Hello": "World"} \ No newline at end of file diff --git "a/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/calc_deposit.py" "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/calc_deposit.py" new file mode 100644 index 00000000..fc759c97 --- /dev/null +++ "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/calc_deposit.py" @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +def calc_deposit(duration:int, rate:float, sum:int): + res = sum + for i in range(duration): + res += res * rate / 100 + print(res) +duration, rate, sum = input("Type number the folowing order duration, rate, sum: ").split() + +calc_deposit(int(duration), float(rate), int(sum)) + diff --git "a/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/int_cmp.py" "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/int_cmp.py" new file mode 100644 index 00000000..c503d0d4 --- /dev/null +++ "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/int_cmp.py" @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +a, b = input("Type two numbers: ").split() +a = int(a) +b = int(b) +if a > b: + print("1") +elif a == b: + print("0") +else: + print("-1") + diff --git "a/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/max_of_three.py" "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/max_of_three.py" new file mode 100644 index 00000000..b2245101 --- /dev/null +++ "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/max_of_three.py" @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +def MaxNum(a): + max_num = a[0] + for i in a: + if i > max_num: + max_num = i + return max_num +a = input("Please enter the 3 numbers: ") +a = list(map(int, a.split())) +print("The largest number is: ", MaxNum(a)) + diff --git "a/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/min.py" "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/min.py" new file mode 100644 index 00000000..21f3667c --- /dev/null +++ "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/min.py" @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +def min_num(nums): + if 0 <= len(nums) <= 10000: + if not nums: + print("The list is empty!") + return None + res = nums[0] + for i in nums: + if i < res: + res = i + return res + else: + print("The numbers out of range!") + +num_input = input("Please enter the numbers, there must be spaces between the numbers.: ") +numbers = list(map(int, num_input.split())) +print("The mininmum number is: ", min_num(numbers)) + + \ No newline at end of file diff --git "a/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/pow_a_b.py" "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/pow_a_b.py" new file mode 100644 index 00000000..0b6ce9b7 --- /dev/null +++ "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/pow_a_b.py" @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +def sum_sqr(n): + num = 0 + if int(n) >= 1 and int(n) <= 10860: + for i in range(1, n + 1): + num += i ** 2 + print(num) + else: + print("Please provide a positive number and in a range of 1 to 10860!") +num = input("Please enter a number: ") +num = int(num) +sum_sqr(num) \ No newline at end of file diff --git "a/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/print_even_a_b.py" "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/print_even_a_b.py" new file mode 100644 index 00000000..ce74e27f --- /dev/null +++ "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/print_even_a_b.py" @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +def even_num(a, b): + num = [] + for i in range(a, b + 1): + if i % 2 == 0: + num.append(i) + print(num) +a, b = input("Type two numbers: ").split() +a = int(a) +b = int(b) +even_num(a, b) \ No newline at end of file diff --git "a/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/range.py" "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/range.py" new file mode 100644 index 00000000..3dc6f280 --- /dev/null +++ "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/range.py" @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + +def list_range(n): + size = int(n) + if 0 <= size <= 10000: + num = [] + for i in range(1, size + 1): + num.append(i) + print(num) + else: + print("The number is out of range!") + +n = input("Please enter the size of list: ") +list_range(n) \ No newline at end of file diff --git "a/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/sort.py" "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/sort.py" new file mode 100644 index 00000000..dfed1ba0 --- /dev/null +++ "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/sort.py" @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +def nums_sort(nums): + if 0 <= len(nums) <= 10000: + for i in range(len(nums) - 1): + for j in range(len(nums) - i - 1): + if nums[j] > nums[j + 1]: + nums[j], nums[j + 1] = nums[j + 1], nums[j] + return nums +num_input = input("Please enter the numbers, there must be spaces between the numbers.: ") +numbers = list(map(int, num_input.split())) +print(nums_sort(numbers)) diff --git "a/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/sum_num.py" "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/sum_num.py" new file mode 100644 index 00000000..0737a4ca --- /dev/null +++ "b/python/\320\273\320\265\320\263\320\272\320\270\320\265 \320\262\320\276\320\277\321\200\320\276\321\201\321\213/sum_num.py" @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +def sum_nums(nums): + if 0 <= len(nums) <= 10000: + sum = 0 + for i in nums: + sum += i + print(sum) + else: + print("The length of the list is out of the acceptable range!") +nums = input("Please enter the numbers: " ) +numbers = list(map(int, nums.split())) +sum_nums(numbers) \ No newline at end of file diff --git "a/python/\321\201\320\273\320\276\320\266\320\275\321\213\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/SumNum.py" "b/python/\321\201\320\273\320\276\320\266\320\275\321\213\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/SumNum.py" new file mode 100644 index 00000000..90ced2bb --- /dev/null +++ "b/python/\321\201\320\273\320\276\320\266\320\275\321\213\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/SumNum.py" @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 + +def sum_of_range(a, z): + a = int(a) + z = int(z) + n = z - a + 1 + return (n * (a + z)) // 2 + +a, z = input("Please enter the numbers: ").split() +print(sum_of_range(a, z)) \ No newline at end of file diff --git "a/python/\321\201\320\273\320\276\320\266\320\275\321\213\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/leapyear.py" "b/python/\321\201\320\273\320\276\320\266\320\275\321\213\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/leapyear.py" new file mode 100644 index 00000000..5be99242 --- /dev/null +++ "b/python/\321\201\320\273\320\276\320\266\320\275\321\213\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/leapyear.py" @@ -0,0 +1,10 @@ +#!/usr/bin/env python3 +def leapYear(n): + n = int(n) + res = 0 + for i in range(1, n+1): + if i % 4 == 0 and i % 100 != 0 or i % 400 == 0: + res += 1 + return res +num = input("Please enter the number: ") +print(leapYear(num)) \ No newline at end of file diff --git "a/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/__pycache__/correctdate.cpython-312.pyc" "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/__pycache__/correctdate.cpython-312.pyc" new file mode 100644 index 00000000..4559fc47 Binary files /dev/null and "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/__pycache__/correctdate.cpython-312.pyc" differ diff --git "a/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/correctdate.py" "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/correctdate.py" new file mode 100644 index 00000000..e13fc521 --- /dev/null +++ "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/correctdate.py" @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +def leapYear(y): + y = int(y) + + if y % 4 == 0 and y % 100 != 0 or y % 400 == 0: + return True + +def checkdate(d, m, y): + MAX_VALID_YR = 9999; + MIN_VALID_YR = 1800; + y = int(y) + m = int(m) + d = int(d) + if y < int(MIN_VALID_YR) or y > int(MAX_VALID_YR): + return False + if m < 1 or m > 12: + return False + if d < 1 or d > 31: + return False + + if m == 2: + if leapYear(y): + return d <= 29 + else: + return d <= 28 + if m == 4 or m == 6 or m == 9 or m == 11: + return d <= 30 + return True +# d, m, y = input("Please enter date in format dd.mm.yyyy: ").split(".") +# print(checkdate(d, m, y)) +# Please Uncomment if you want to check this function! + \ No newline at end of file diff --git "a/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/dateseazon.py" "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/dateseazon.py" new file mode 100644 index 00000000..14665d5d --- /dev/null +++ "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/dateseazon.py" @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +from correctdate import checkdate + +def CheckSeason(d, m, y): + y = int(y) + m = int(m) + d = int(d) + if checkdate(d, m, y): + match m: + case 6 | 7 | 8: + print("Summer") + + case 9 | 10: + print("Fall") + + case 11 | 12 | 1 | 2: + print("Winter") + + case 3 | 4 | 5: + print("Spring") + else: + print("Invalid date!") + +d, m, y = input("Please enter date in format dd.mm.yyyy: ").split(".") +CheckSeason(d, m, y) \ No newline at end of file diff --git "a/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/even_odd.py" "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/even_odd.py" new file mode 100644 index 00000000..0f6dc9c6 --- /dev/null +++ "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/even_odd.py" @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +def even_odd(n): + if n % 2 == 0: + print("Even!") + else: + print("Odd!") +try: + num = int(input("Please enter a number: ")) + even_odd(num) +except ValueError: + print("Invalid input! Please enter a valid number.") \ No newline at end of file diff --git "a/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/fibonacci.py" "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/fibonacci.py" new file mode 100644 index 00000000..acaa09de --- /dev/null +++ "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/fibonacci.py" @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 +import math + +def is_perfect_square(x): + s = int(math.sqrt(x)) + + return s * s == x + +def fibnum(n): + + pos_test = 5 * (n ** 2) + 4 + neg_test = 5 * (n ** 2) - 4 + + return is_perfect_square(pos_test) or is_perfect_square(neg_test) + + +num = int(input("Enter a number: ")) +if fibnum(num): + print(f"{num} is a Fibonacci number") +else: + print(f"{num} is not a Fibonacci number") \ No newline at end of file diff --git "a/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/list_perfectnum.py" "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/list_perfectnum.py" new file mode 100644 index 00000000..8b71f47f --- /dev/null +++ "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/list_perfectnum.py" @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +def listperfect(n): + perfect_nums = [6, 28, 496] + s = [] + try: + n = int(n) + if n < 0 or n > 1000: + print("The number is out of range!") + return [] + except ValueError: + print("Invalid input! Please enter a valid number.") + return [] + + + for i in range (1, n): + if i in perfect_nums: + s.append(i) + return s + + +num = input("Please enter the number: ") +print(listperfect(num)) diff --git "a/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/pallindrom.py" "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/pallindrom.py" new file mode 100644 index 00000000..f281d89f --- /dev/null +++ "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/pallindrom.py" @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +def pallindrom(w): + reversed_word = w[::-1] + if not w: # Check for empty string + raise ValueError("Input cannot be empty!") + if w == reversed_word: + print("This word is pallindrom!") + else: + print("This word is not pallindrom!") + +w = input("Please enter a word: ") +pallindrom(w) diff --git "a/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/perfectnum.py" "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/perfectnum.py" new file mode 100644 index 00000000..b5b8dbd7 --- /dev/null +++ "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/perfectnum.py" @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +def perfectnum(n): + n = int(n) + sum = 0 + for i in range(1, n): + if n % i == 0: + sum += i + if sum == n: + return "Perfect number" + else: + return "Not a perfect number" + +num = input("Please enter the number: ") +print(perfectnum(num)) \ No newline at end of file diff --git "a/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/prime.py" "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/prime.py" new file mode 100644 index 00000000..6fbd6b2c --- /dev/null +++ "b/python/\321\201\321\200\320\265\320\264\320\275\320\270\320\265 \320\267\320\260\320\264\320\260\321\207\320\270/prime.py" @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 +import math +def prime_num(n): + if n <= 1: + return "The number isn't prime" + for i in range(2, int(math.sqrt(n)) + 1): + if n % i == 0: + return "The number isn't prime" + + return "The number is prime" + +num = int(input("Please enter a number: ")) +print(prime_num(num)) \ No newline at end of file