This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from math import sqrt | |
| from microbit import * | |
| s3 = sqrt(3) | |
| pattern0 = [(1, 1), (-1, -1), (-s3, s3)] | |
| def magnify_by(n): | |
| def transf(x, y): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from functools import partial | |
| import turtle | |
| window = turtle.Screen() | |
| def draw_polygon(sides, color): | |
| turtle.color(color) | |
| angle = 360/sides | |
| for i in range(sides): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Solution for | |
| https://adventofcode.com/2022/day/2 | |
| first and second half | |
| """ | |
| from typing import List, Callable | |
| RESULT_SCORES = {"draw": 3, "win": 6, "loose": 0} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import argparse | |
| from pathlib import Path | |
| import os | |
| def get_latest_file(directory: Path) -> Path: | |
| """ | |
| Finds the most recently modified file in a directory and its subdirectories. | |
| Args: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from test_cases import cases | |
| from irish_possessive_golf import f | |
| def test_all(): | |
| for i, (x, y, result) in enumerate(cases): | |
| my_result = f(x, y) | |
| assert my_result == result, f"{x}, {y} should give {result}, not {my_result} ({i+1})" | |
| print("All succeeded") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import fnmatch | |
| import os | |
| import sys | |
| from pathlib import Path | |
| eleresi_ut = Path.home() / "Documents" | |
| minta = 'Co*t*.*' | |
| # good old walk | |
| for root, dirs, files in os.walk(eleresi_ut): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| I've just returned from EuroPython Conference, and there was a good presentation: "From Jupyter Notebooks to a Python Package: The Best of Both Worlds". If I'm correct the video is not (yet?) on youtube, but the repo and the slides are here. | |
| https://github.com/sesise0307/europython2023-package | |
| I've used to use a similar setup, but I'll do the same (just w/ PyCharm instead of VSCode). | |
| Creating packag(es) from frequently used functionalities. | |
| %load_ext autoreload%autoreload 2 | |
| in Jupyter, and then from Jupyter (starting with !) or from commandline | |
| pip install --editable <path> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from openpyxl import Workbook | |
| text = "" # Including three bytes: hexadecimal FFBFBF resulting ValueError | |
| # text = '\x16' # resulting IllegalCharacterError | |
| wb = Workbook() | |
| ws = wb.active | |
| ws.append([text]) | |
| wb.save("test.xlsx") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python3 | |
| from pathlib import Path | |
| from string import ascii_letters | |
| fs = "🌼🌺🌷🪻🌹🥀🪷🌸🌻🍄🎂🎹" | |
| text = Path("MARTI.txt").read_text() | |
| text = text.replace(".", fs[4]).replace("\\", fs[0]).replace("?", fs[4]) | |
| chars = set(ascii_letters + "öéűáőüíóúÖÉŰÁŐÜÍÓÚ!") |
OlderNewer