This file contains 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
#!python3 | |
import requests | |
from urllib.parse import quote | |
from prettytable import PrettyTable | |
def measure(user, MAX_XP, MAX_LVL, MAX_ELITE_XP): | |
SKILL_NAMES = ["Total level", "Attack", "Defence", "Strength", "Constitution", | |
"Ranged", "Prayer", "Magic", "Cooking", "Woodcutting", "Fletching", | |
"Fishing", "Firemaking", "Crafting", "Smithing", "Mining", | |
"Herblore", "Agility", "Thieving", "Slayer", "Farming", |
This file contains 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
@echo off | |
rem Define a (local) name for the temporary file | |
setlocal | |
set temp="tmp.txt" | |
rem Copy the list of outdated modules to a text file | |
call pip list --outdated > %temp% | |
rem Process the text file to only contain module names |
This file contains 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/env python3 | |
from typing import Generator, Optional | |
from numbers import Real | |
def my_range(start: Real, stop: Optional[Real]=None, step: Real=1) -> Generator[Real, None, None]: | |
""" An example definition of Python 3's range-class as a function """ | |
# If only one argument was provided, use that | |
# argument as the goal and set start to 0 |
This file contains 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
# log(log(sqrt(4), 4), (sqrt(4)/4)) == 1 | |
import math | |
def repeat(func, n): | |
x = 4 | |
for _ in range(n): | |
x = func(x) | |
return x |
This file contains 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 sys | |
from typing import TextIO | |
def my_print(*args: list, file: TextIO=sys.stdout, sep: str=' ', end: str='\n', flush: bool=False) -> None: | |
""" | |
Prints the values to a stream, or to sys.stdout by default. | |
Optional keyword arguments: | |
file: a file-like object (stream); defaults to the current sys.stdout. | |
sep: string inserted between values, default a space. | |
end: string appended after the last value, default a newline. |
This file contains 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/env python3 | |
# Written by Lari Liuhamo | |
import string | |
from typing import Generator | |
def caesar_cipher(message: str, shift: int, alphabet=string.ascii_uppercase) -> str: | |
""" | |
Performs the Caesar cipher on a given message (string) by shifting all characters using the given shift. |
This file contains 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/env python3 | |
from typing import List | |
class RSAConfig: | |
def __init__(self, p, q, e, d): | |
self.p = p | |
self.q = q | |
self.n = p * q | |
self.phi = (p-1) * (q-1) | |
self.e = e |
This file contains 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/env python3 | |
from typing import Optional, List, Generator | |
def prime_gen(limit: Optional[int]=None) -> Generator[int, None, None]: | |
"""Generates prime numbers with an optional upper limit""" | |
primes = [2] | |
n = 3 | |
while limit is None or limit >= n: | |
for prime in primes: |
This file contains 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/env python3 | |
from typing import Any, Callable, Generator, Iterable, List | |
def my_map(func: Callable[[Any, ...], Any], *iterables: List[Iterable[Any]]) -> Generator[Any, None, None]: | |
""" | |
Mimics the built-in map function, accepting any number of iterables | |
and yielding values returned by the given function. | |
""" | |
OlderNewer