top of page
ToucanSway


PYTHON CODING
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = fig.add_subplot(111,...

waclaw_koscielniak
Oct 41 min read
Â
Â
Â


PYTHON CODING
from functools import reduce nums = [2, 3, 4] product = reduce(lambda x, y: x * y, nums) nums.append(5) s = reduce(lambda x, y: x + y,...

waclaw_koscielniak
Oct 31 min read
Â
Â
Â


PYTHON CODING
import yfinance as yf from datetime import datetime symbol = input("Enter symbol: ").upper() stock = yf.Ticker(symbol) try: price =...

waclaw_koscielniak
Oct 21 min read
Â
Â
Â


PYTHON CODING
from cryptography.fernet import Fernet key = Fernet.generate_key() print("Encryption Key:", key.decode()) cipher = Fernet(key) message =...

waclaw_koscielniak
Sep 301 min read
Â
Â
Â


QR CODE GENERATOR IN PYTHON
import qrcode from PIL import Image qr = qrcode.QRCode( version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10,...

waclaw_koscielniak
Sep 291 min read
Â
Â
Â


PYTHON CODING
from functools import reduce nums = [2, 3, 4, 5] product = reduce(lambda x, y: x * y, nums) nums.remove(3) s = reduce(lambda x, y: x + y,...

waclaw_koscielniak
Sep 291 min read
Â
Â
Â


PYTHON CODING
import statistics data = [2, 4, 4, 6, 8] mean_val = statistics.mean(data) median_val = statistics.median(data) mode_val =...

waclaw_koscielniak
Sep 271 min read
Â
Â
Â


PYTHON CODING
from PIL import Image, ImageDraw import random w,h,l = 1000,1000,333 img = Image.new("RGB", (w,h), "black") draw = ImageDraw.Draw(img)...

waclaw_koscielniak
Sep 251 min read
Â
Â
Â


PYTHON CODING
import os from pathlib import Path p = Path("sample.txt") p.write_text("Hello") print(os.path.isfile("sample.txt"), p.stat().st_size)...

waclaw_koscielniak
Sep 231 min read
Â
Â
Â


PYTHON CODING
import glob, os with open("a.txt", "w") as f: f.write("A") with open("b.txt", "w") as f: f.write("B") print(len(glob.glob("*.txt")))...

waclaw_koscielniak
Sep 221 min read
Â
Â
Â


PYTHON CODING
from fractions import Fraction f1 = Fraction(3, 4) f2 = Fraction(2, 3) result = f1 * f2 + Fraction(1, 6) print(result, float(result))...

waclaw_koscielniak
Sep 191 min read
Â
Â
Â


PYTHON CODING
import numpy as np import matplotlib.pyplot as plt number = 500 x = np.random.rand(number)*10 y = np.random.rand(number)*10 sizes =...

waclaw_koscielniak
Sep 171 min read
Â
Â
Â


PYTHON CODING
import asyncio async def double(x): await asyncio.sleep(0.05) return x * 2 async def main(): results = await asyncio.gather(double(3),...

waclaw_koscielniak
Sep 161 min read
Â
Â
Â


PYTHON CODING
import json data = {"x": 5, "y": 10} js = json.dumps(data) parsed = json.loads(js) parsed["z"] = parsed["x"] * parsed["y"]...

waclaw_koscielniak
Sep 151 min read
Â
Â
Â


PYTHON CODING
from functools import reduce nums = [1, 2, 3, 4] res = reduce(lambda x, y: x * y, nums, 2) print(res) nums.append(5) res2 = reduce(lambda...

waclaw_koscielniak
Sep 131 min read
Â
Â
Â


PYTHON CODING
nums = [1, 2, 3, 4] ref = nums copy = nums[:] ref[0] = 99 copy[1] = 100 print(nums, copy) [Running] python3 -u...

waclaw_koscielniak
Sep 121 min read
Â
Â
Â


PYTHON CODING
def gen(): for i in range(3): yield i * i g = gen() print(next(g)) print(sum(g)) [Running] python3 -u "/Users/name/test/test823.py" 0...

waclaw_koscielniak
Sep 111 min read
Â
Â
Â


PYTHON CODING
def outer(x): def inner(y): return x + y return inner f = outer(5) print(f(3)) print(outer(10)(2)) [Running] python3 -u...

waclaw_koscielniak
Sep 101 min read
Â
Â
Â


PYTHON CODING
import weakref class A: pass a = A() r = weakref.ref(a) print(r() is a) del a print(r() is None) [Running] python3 -u...

waclaw_koscielniak
Sep 81 min read
Â
Â
Â


PYTHON CODING
import heapq nums = [5, 1, 8, 3] heapq.heapify(nums) heapq.heappush(nums, 0) print(heapq.heappop(nums), nums[0]) [Running] python3 -u...

waclaw_koscielniak
Sep 61 min read
Â
Â
Â
bottom of page