initial commit
This commit is contained in:
commit
3b0d8c9357
8 changed files with 107 additions and 0 deletions
20
.gitea/workflows/lint.yaml
Normal file
20
.gitea/workflows/lint.yaml
Normal file
|
@ -0,0 +1,20 @@
|
|||
name: Actions
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
|
||||
jobs:
|
||||
Lint Code (Ruff & Pylint):
|
||||
runs-on: docker
|
||||
container: www.coastalcommits.com/seaswimmerthefsh/actionscontainers-seacogs:latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Analysing code with Ruff
|
||||
run: ./.venv/bin/ruff check $(git ls-files '*.py')
|
||||
continue-on-error: true
|
||||
|
||||
- name: Analysing code with Pylint
|
||||
run: ./.venv/bin/pylint --rcfile=.forgejo/workflows/config/.pylintrc $(git ls-files '*.py')
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
__pycache__
|
1
Blastoff!/README.md
Normal file
1
Blastoff!/README.md
Normal file
|
@ -0,0 +1 @@
|
|||
# Blastoff!
|
1
Blastoff!/__init__.py
Normal file
1
Blastoff!/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
35,32,100,111,110,39,116,32,109,111,100,105,102,121,32,116,104,105,115,32,102,105,108,101
|
27
Blastoff!/blastoff.py
Normal file
27
Blastoff!/blastoff.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from time import sleep
|
||||
|
||||
def countdown(n: int) -> None:
|
||||
if n <= 0:
|
||||
print('Blastoff!')
|
||||
else:
|
||||
print(n)
|
||||
sleep(1)
|
||||
countdown(n-1)
|
||||
|
||||
def countup(n: int) -> None:
|
||||
if n >= 0:
|
||||
print('Blastoff!')
|
||||
else:
|
||||
print(n)
|
||||
sleep(1)
|
||||
countup(n+1)
|
||||
|
||||
def count(n: int) -> None:
|
||||
if int(n) >= 0:
|
||||
countdown(n)
|
||||
else:
|
||||
countup(n)
|
||||
|
||||
if __name__ == "__main__":
|
||||
num = input("Enter a number: ")
|
||||
count(int(num))
|
3
Online Store/README.md
Normal file
3
Online Store/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Online Store
|
||||
|
||||
wip
|
1
Online Store/__init__.py
Normal file
1
Online Store/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
# don't modify this file
|
53
Online Store/main.py
Normal file
53
Online Store/main.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
prices_dict = {
|
||||
"grapes": 200,
|
||||
"oranges": 400,
|
||||
"apples": 600
|
||||
}
|
||||
|
||||
def get_discounted_prices(*prices: int) -> float:
|
||||
# make a set from the passed arguments to avoid duplicates
|
||||
prices_set = set(prices)
|
||||
|
||||
# if there's still more than three values in the set, raise an error
|
||||
if len(prices_set) > 3:
|
||||
raise ValueError("This function only takes up to three arguments.")
|
||||
|
||||
# add the prices together
|
||||
price_sum = sum(prices)
|
||||
# https://seafsh.cc/u/HR0thZ.png
|
||||
|
||||
# apply discounts for the sum
|
||||
if len(prices_set) == 3:
|
||||
return float(price_sum * 0.75)
|
||||
|
||||
elif len(prices_set) == 2:
|
||||
return float(price_sum * 0.9)
|
||||
|
||||
else:
|
||||
return float(price_sum)
|
||||
|
||||
def print_row(item: str, price: str, bold: bool = False) -> None:
|
||||
# ANSI color codes
|
||||
blue = "\033[34m" # Blue
|
||||
green = "\033[32m" # Green
|
||||
bold_s = "\033[1m" if bold is True else "" # Bold, use an empty string instead of None, because None will be converted to a string by print()
|
||||
reset = "\033[0m" # Reset to default color
|
||||
|
||||
# apply ansi styling for bold, then blue, then offset the first string by 25 characters to the left.
|
||||
# reset formatting, then do the same thing for the second string but with green as the
|
||||
# ansi color code instead of blue and offsetting to the right
|
||||
print(f" {bold_s}{blue}{item:<25}{reset} {bold_s}{green}{price:>25}{reset}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
print("Online Store")
|
||||
print("⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯")
|
||||
print_row("Products", "Price", True)
|
||||
print_row("Grapes", get_discounted_prices(prices_dict["grapes"]))
|
||||
print_row("Orange", get_discounted_prices(prices_dict["oranges"]))
|
||||
print_row("Apple", get_discounted_prices(prices_dict["apples"]))
|
||||
print_row("Grapes & Oranges Combo", get_discounted_prices(prices_dict["grapes"], prices_dict["oranges"]))
|
||||
print_row("Oranges & Apples Combo", get_discounted_prices(prices_dict["oranges"], prices_dict["apples"]))
|
||||
print_row("Grapes & Apples Combo", get_discounted_prices(prices_dict["grapes"], prices_dict["apples"]))
|
||||
print_row("Fruit Gift Pack", get_discounted_prices(prices_dict["grapes"], prices_dict["apples"], prices_dict["oranges"]))
|
||||
print("⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯")
|
||||
print("For delivery Contact: (987) 646-78899") # lol?
|
Loading…
Add table
Reference in a new issue