-
You can't use text other than that provided in the question
-
You can't use operator symbols (eg.
[]
,%=
,+
,==
, etc...) unless representing mathematical operations on numbers -
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.
-
x = 12
-
"Hello there"
-
[1, 2, 3, "a", "b", "c"]
-
(1, 2, 3)
-
"tHe DaRk KnIgHt".lower()
-
12 + 3j
-
"tHe DaRk KnIgHt".capitalize()
-
{"a": 1, "b": 2, "c": 3}.items()
-
{"a": 1, "b": 2, "c": 3}
-
some_list[3] = "new value"
-
"tHe DaRk KnIgHt".title()
-
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
-
{"a": 1, "b": 2, "c": 3}.keys()
-
~13
-
15 << 3
![](imgs/sim 15.jpg)
-
12 | 5
-
set([1, 2, 3, 4, 2, 2])
-
"tHe DaRk KnIgHt"[2:-2]
-
[1, 2, 3, 4, 5][3]
-
x %= 2
-
{"a": 1, "b": 2, "c": 3}.values()
-
"tHe DaRk KnIgHt".split(" ")
-
{"a": 1, "b": 2, "c": 3}["b"]
-
y = [1, 2, 3].copy()
-
[1, 2, 3, 4, 5, 6][2:-2]
-
a, b, c, d = (1, 2, 3, 4)
-
(1, 2, 3, 4, 5)[1:-1]
-
[1, 2, 3, 4, 5].insert(3, 0)
-
"tHe DaRk KnIgHt".replace(" ", "-")
-
x = 12 f"{x} is even"
-
if x % 2 == 0: print("x is even")
-
for value in [1, 3, 5, 7, 11]: print(f"{value} is prime")
-
[i for i in [1, 2, 3, 4]]
-
for n in range(10): print(2 ** n)
-
[i for i in range(5)]
-
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 ifx
is zero first? why that specific order? -
while x < 10: print(2 ** x) x += 1
-
[2 ** i for i in range(5)]
-
for i in range(5): print([i * n for n in range(5)])
-
for i in range(5): for value in [i * n for n in range(5)]: print(value)
-
for x in range(10): print(2 ** x)
-
for value in [i * n for i in range(5) for n in range(5)]: print(value)
-
matrix = [] for i in range(3): row = [] for n in range(3): row.append(i * n) matrix.append(row)
-
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
-
for x in range(5): for n in range(5): print(x * n)
-
for x in range(5): for n in range(x): print(x * n)
-
for value in number_list: if value % 5 == 2: break print("a 5n+2 value exists")
-
for value in number_list: if value % 2 == 0: continue print("value is odd")
-
for value in [1, 2, 3, 4, 5, 6]: do_something(value)
-
primeFlag = False for value in number_list: if is_prime(value): primeFlag = True break
-
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")
-
while True: if break_condon(some_value): break do_some_stuff(some_other_value) checked_value_count += 1
-
sin(x)
-
sin(cos(x))
-
calc_dct([[1, 2, 3], [2, 3, 4], [3, 4, 5]])
-
dct_value = calc_dct([[1, 2, 3], [2, 3, 4], [3, 4, 5]]) compress(dct_value)
-
compress(calc_dct([[1, 2, 3], [2, 3, 4], [3, 4, 5]]))
-
auto_gen_fn = a_function_that_returns_another_function(x) auto_gen_fn(return_fn_value)
-
a_function_that_returns_another_function(x)(return_fn_value)