Quick Sort implementation in python
Magic Numbers

arr = [randint(0, 30) for _ in range(20)]


What are 0, 30, and 20 supposed to represent? I would assign these to variables to make it more clear

Type Hints

This

def swap(array, a, b):


can be this

def swap(array: list, a: int, b: int) -&gt; None:


These allow you to show what types of parameters are accepted, and what types are returned from the functions.

Main Guard

This

arr = [randint(0, 30) for _ in range(20)]
print(arr)
quick_sort(arr)
print(arr)


should be put in a main guard, like so

if __name__ == '__main__':
    arr = [randint(0, 30) for _ in range(20)]
    print(arr)
    quick_sort(arr)
    print(arr)


This prevents this code from running if you decide to import this module from another module/program.