Code Snippets — Python

Advanced · code

Code Snippets — Python

Practice typing real-world Python code

Practice text preview

  • def fibonacci(n): a, b = 0, 1; result = []; for _ in range(n): result.append(a); a, b = b, a + b; return result
  • class Node: def __init__(self, value): self.value = value; self.next = None from typing import List def quicksort(arr: List[int]) -> List[int]: return arr if len(arr) <= 1 else quicksort([x for x in arr[1:] if x < arr[0]]) + [arr[0]] + quicksort([x for x in arr[1:] if x >= arr[0]])