-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython-t.txt
137 lines (95 loc) · 2.64 KB
/
python-t.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
Charles Truscott Watters, MIT Python
declarative vs. imperative knowledge
int, float, string, set, tuple, list, dictionary, class, object, function, function invocation, function return
combined type, expression, operator, operand
+ - * / // % ** ( ) != == and, or, not += -= *= /= //= %= **=
& | ^ ~ << >> &= |= ^= ~= <<= >>= . * ** [ ] [i:j] [i:j:k] [i][j] [i][j][k]
: ; __ , = @
True, False, lambda x: x ** 2, lambda x, y: x ** y, yield, from x import y as z
break, continue, is, is not, in, is in
assert, global, nonlocal, pass, del
try:
body
except ValueError:
body
except IOError:
body
finally:
body
else:
body
if filename.endswith(".txt") == False: raise ValueError("Must end with .txt, other data formats not supported")
Exception Handling, Exception Handling Classes
for x in range(start, stop - 1, step):
for x in a:
for y in x:
for x in a:
for y in b:
while(True):
body
while(bool):
while(bool):
body
def recurse(a, b):
base case x:
base case y:
base case z:
body:
recurse(a - 1, b - 1)
return
recursion, iteration
if (bool):
if (bool):
if (bool):
elif (bool):
elif (bool):
else:
elif (bool):
elif (bool):
else:
elif (bool):
elif (bool):
else:
match(case / object):
case x:
body
case y:
body
case z:
body
branching, control flow, conditionals
def function(args):
body
return
def main():
body
if __name__ == "__main__": main()
abstraction, decomposition, function-oriented programming
class Person(object):
def __init__(self, name, age, dob):
self.name = name
self.age = age
self.dob = dob
def __repr__(self):
pass
def __iter__(self):
pass
def __str__(self):
pass
encapsulation, inheritance, polymorphism, data and method attributes, generators, decorators
Python Standard Library, Algorithmic Complexity, Algorithms and Data Structures, Sorting and Searching, Requirements Analysis and Software Prototyping
Algorithmic Complexity
- step
- random access machine
- time constraint
- best case, worst case, average case
- lower, upper bound
- O(n), asymptotic notation, upper bound
- ϴ(n), theta notation, lower bound
- counting steps, branches, operators, operations, iteration, recursion, variables
- order of growth in respect of some variable `n`
constant, linear, logarithmic, log-linear, polynomial (e.g. binomial trinomial quadratic), exponential time
- additive and multiplicative constants
e.g. prime number discovery algorithm is 5n + n / 2 for ϴ(n) but e^(5n + n / 2) for large n such as O(n)
Thursday 5 January 2023
Charles Truscott