top of page
ToucanSway


PYTHON CODING
import cv2 import numpy as np img = np.zeros((100, 200, 3), dtype=np.uint8) print(img.shape) [Running] python3 -u...

waclaw_koscielniak
Aug 191 min read
Â
Â
Â


PYTHON CODING
def append_item(item, container=[]): container.append(item) return container print(append_item(1), append_item(2)) [Running] python3 -u...

waclaw_koscielniak
Aug 181 min read
Â
Â
Â


PYTHON CODING
import pandas as pd s = pd.Series([5, 8, 12, 18, 22]) s[s < 10] *= 2 print(s.sum()) [Running] python3 -u "/Users/name/test/test95.py" 78...

waclaw_koscielniak
Aug 151 min read
Â
Â
Â


PYTHON CODING
import numpy as np arr = np.array([3, 15, 8, 22, 7]) mask = arr < 10 arr[mask] = 0 print(np.sum(arr)) [Running] python3 -u...

waclaw_koscielniak
Aug 81 min read
Â
Â
Â


PYTHON CODING
def make_funcs(): return [lambda x: i * x for i in range(3)] funcs = make_funcs() results = [f(2) for f in funcs] print(results)...

waclaw_koscielniak
Aug 41 min read
Â
Â
Â


PYTHON CODING
from collections import Counter def letter_counts(word): c = Counter(word) for k, v in c.items(): yield k, v...

waclaw_koscielniak
Jul 311 min read
Â
Â
Â


PYTHON QUIZ
def func(x, y): return x if y > 0 else y result = func(5, 0) + func(0, -5) print(result) [Running] python3 -u...

waclaw_koscielniak
Jul 261 min read
Â
Â
Â


PYTHON CODING
def flatten(lst): for item in lst: if isinstance(item, list): yield from flatten(item) else: yield item print(list(flatten([1,...

waclaw_koscielniak
Jul 231 min read
Â
Â
Â


PYTHON CODING
def track_yields(): for i in range(3): print(f"Yielding {i}") yield i print("Done") for val in track_yields(): pass [Running]...

waclaw_koscielniak
Jul 211 min read
Â
Â
Â


PYTHON CODING
def chooser(val): if val == "a": yield from [1, 2] else: yield from [3, 4] print(list(chooser("b"))) [Running] python3 -u...

waclaw_koscielniak
Jul 171 min read
Â
Â
Â


PYTHON CODING
def early_exit(): for i in range(10): if i > 3: return yield i print(list(early_exit())) [Running] python3 -u...

waclaw_koscielniak
Jul 161 min read
Â
Â
Â


PYTHON QUIZ
check1 = ['Learn', 'Quiz', 'Practice', 'Contribute'] check2 = check1 check3 = check1[:] check2[0] = 'Code' check3[1] = 'Mcq' count = 0...

waclaw_koscielniak
Jul 141 min read
Â
Â
Â


PYTHON CODING
def values(): for i in range(10): yield i filtr = filter(lambda x: x % 2 == 0, values()) print(list(filtr)) [Running] python3 -u...

waclaw_koscielniak
Jul 131 min read
Â
Â
Â


PYTHON CODING
a = True b = False c = False if a or b and c: print("Correct") else: print("Incorrect") [Running] python3 -u...

waclaw_koscielniak
Jul 101 min read
Â
Â
Â


PYTHON CODING
def squares(): for i in range(1, 4): yield i*i s = squares() print(list(s)) [Running] python3 -u "/Users/name/test/test61.py" [1, 4,...

waclaw_koscielniak
Jul 101 min read
Â
Â
Â


PYTHON CODING
import numpy as np import matplotlib.pyplot as plt n = 5000 theta = np.linspace(0, 12 * np.pi, n) r = np.linspace(0, 1, n) + 0.2 *...

waclaw_koscielniak
Jul 91 min read
Â
Â
Â


PYTHON CODING
def g(): yield 1 yield 2 x = g() print(next(x)) print(next(x)) print(next(x)) [Running] python3 -u "/Users/name/test/test47.py" 1 2...

waclaw_koscielniak
Jul 91 min read
Â
Â
Â


PYTHON CODING
def string_only(f): def wrap(x): return f(x) if isinstance(x, str) else "Invalid" return wrap @string_only def echo(s): return s + s...

waclaw_koscielniak
Jul 81 min read
Â
Â
Â


PYTHON CODING
def pack(f): def wrap(x): return (f(x), x) return wrap @pack def square(x): return x ** 2 print(square(3)[1]) [Running] python3 -u...

waclaw_koscielniak
Jul 71 min read
Â
Â
Â


PYTHON CODE
def outer(): funcs = [] for i in range(3): def inner(i=i): return i * 2 funcs.append(inner) return funcs a, b, c = outer()...

waclaw_koscielniak
Jul 31 min read
Â
Â
Â
bottom of page