Skip to content

Latest commit

 

History

History
437 lines (301 loc) · 6.87 KB

flow visualization dictionary.md

File metadata and controls

437 lines (301 loc) · 6.87 KB

The rules

  1. You can't use text other than that provided in the question

  2. You can't use operator symbols (eg. [], %=, +, ==, etc...) unless representing mathematical operations on numbers

  3. your diagram should represent the action/process/flow of the given question, not the initial and/or final states. It should be the most generalized possible representation.

Simple Stuff

  1. x = 12

  2. "Hello there"

  3. [1, 2, 3, "a", "b", "c"]

  4. (1, 2, 3)

  5. "tHe DaRk KnIgHt".lower()

  6. 12 + 3j

  7. "tHe DaRk KnIgHt".capitalize()

  8. {"a": 1, "b": 2, "c": 3}.items()

  9. {"a": 1, "b": 2, "c": 3}

  10. some_list[3] = "new value"

  11. "tHe DaRk KnIgHt".title()

  12. [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

  13. {"a": 1, "b": 2, "c": 3}.keys()

  14. ~13

  15. 15 << 3

    ![](imgs/sim 15.jpg)

  16. 12 | 5

  17. set([1, 2, 3, 4, 2, 2])

  18. "tHe DaRk KnIgHt"[2:-2]

  19. [1, 2, 3, 4, 5][3]

  20. x %= 2

  21. {"a": 1, "b": 2, "c": 3}.values()

  22. "tHe DaRk KnIgHt".split(" ")

  23. {"a": 1, "b": 2, "c": 3}["b"]

  24. y = [1, 2, 3].copy()

  25. [1, 2, 3, 4, 5, 6][2:-2]

  26. a, b, c, d = (1, 2, 3, 4)

  27. (1, 2, 3, 4, 5)[1:-1]

  28. [1, 2, 3, 4, 5].insert(3, 0)

  29. "tHe DaRk KnIgHt".replace(" ", "-")

  30. x = 12
    f"{x} is even"

Comparatively complex stuff

  1. if x % 2 == 0:
        print("x is even")

  2. for value in [1, 3, 5, 7, 11]:
        print(f"{value} is prime")

  3. [i for i in [1, 2, 3, 4]]

  4. for n in range(10):
        print(2 ** n)

  5. [i for i in range(5)]

  6. if x > 0:
        print("value is positive")
    elif x < 0:
        print("value is negative")
    elif x == 0:
        print("value is neutral")
    else:
        print("value is an alien shaolin monk who knows magic and wants Stan Lee's autograph")

    BONUS QN: why not check if x is negative before x is positive? or if x is zero first? why that specific order?

  7. while x < 10:
        print(2 ** x)
        x += 1

  8. [2 ** i for i in range(5)]

  9. for i in range(5):
        print([i * n for n in range(5)])

  10. for i in range(5):
        for value in [i * n for n in range(5)]:
            print(value)

  11. for x in range(10):
        print(2 ** x)

  12. for value in [i * n for i in range(5) for n in range(5)]:
        print(value)

  13. matrix = []
    
    for i in range(3):
        row = []
        for n in range(3):
            row.append(i * n)
    
        matrix.append(row)

  14. matrix = [[i * n for n in range(3)] for i in range(3)]

    NOTE: pay attention to the order, then have a look qt QN.13 when done

  15. for x in range(5):
        for n in range(5):
            print(x * n)

  16. for x in range(5):
        for n in range(x):
            print(x * n)

  17. for value in number_list:
        if value % 5 == 2:
            break
    
    print("a 5n+2 value exists")

  18. for value in number_list:
        if value % 2 == 0:
            continue
    
        print("value is odd")

  19. for value in [1, 2, 3, 4, 5, 6]:
        do_something(value)

  20. primeFlag = False
    
    for value in number_list:
        if is_prime(value):
            primeFlag = True
            break

  21. if x % 2 == 0:
        print("x is even")
    
    if x % 5 == 2:
        print("x is 5n+2 for some n ∈ N")
    else:
        print("x is of no concern to us")

  22. while True:
        if break_condon(some_value):
            break
    
        do_some_stuff(some_other_value)
    
        checked_value_count += 1

  23. sin(x)

  24. sin(cos(x))

  25. calc_dct([[1, 2, 3], [2, 3, 4], [3, 4, 5]])

  26. dct_value = calc_dct([[1, 2, 3], [2, 3, 4], [3, 4, 5]])
    compress(dct_value)

  27. compress(calc_dct([[1, 2, 3], [2, 3, 4], [3, 4, 5]]))

  28. auto_gen_fn = a_function_that_returns_another_function(x)
    auto_gen_fn(return_fn_value)

  29. a_function_that_returns_another_function(x)(return_fn_value)