diff options
Diffstat (limited to '')
| -rw-r--r-- | src/Lecture4/live/live.zip | bin | 0 -> 2264 bytes | |||
| -rw-r--r-- | src/Lecture4/live/live1.py | 17 | ||||
| -rw-r--r-- | src/Lecture4/live/live2.py | 7 | ||||
| -rw-r--r-- | src/Lecture4/live/live3.py | 9 | ||||
| -rw-r--r-- | src/Lecture4/live/live4.py | 39 | ||||
| -rw-r--r-- | src/Lecture4/live/live_interactive.py | 172 |
6 files changed, 244 insertions, 0 deletions
diff --git a/src/Lecture4/live/live.zip b/src/Lecture4/live/live.zip new file mode 100644 index 0000000..81e11a8 --- /dev/null +++ b/src/Lecture4/live/live.zip | |||
| Binary files differ | |||
diff --git a/src/Lecture4/live/live1.py b/src/Lecture4/live/live1.py new file mode 100644 index 0000000..da505f2 --- /dev/null +++ b/src/Lecture4/live/live1.py | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | print(2+2) | ||
| 2 | |||
| 3 | x = input("Input something: ") | ||
| 4 | print("Your input was:", x, "of type", type(x)) | ||
| 5 | |||
| 6 | x_number = int(x) | ||
| 7 | print("Converted to a number:", x_number, "of type", type(x_number)) | ||
| 8 | |||
| 9 | if x_number > 10: | ||
| 10 | print("Your number was large!") | ||
| 11 | print("It was larger than 10") | ||
| 12 | z = x_number-10 | ||
| 13 | print("This is a smaller number:", z) | ||
| 14 | else: | ||
| 15 | print("Your number was small") | ||
| 16 | |||
| 17 | print("Bye") | ||
diff --git a/src/Lecture4/live/live2.py b/src/Lecture4/live/live2.py new file mode 100644 index 0000000..041bda3 --- /dev/null +++ b/src/Lecture4/live/live2.py | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | x = int(input("Input something: ")) | ||
| 2 | |||
| 3 | while x > 10: | ||
| 4 | print("Large number!", x) | ||
| 5 | x = x - 1 | ||
| 6 | |||
| 7 | print("Bye") | ||
diff --git a/src/Lecture4/live/live3.py b/src/Lecture4/live/live3.py new file mode 100644 index 0000000..14aa89b --- /dev/null +++ b/src/Lecture4/live/live3.py | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | x = int(input("Input something: ")) | ||
| 2 | |||
| 3 | A = [1,2,3] | ||
| 4 | |||
| 5 | for i in range(2,9): | ||
| 6 | z = 10**i | ||
| 7 | print("A power of 10:", z) | ||
| 8 | |||
| 9 | print("Bye") | ||
diff --git a/src/Lecture4/live/live4.py b/src/Lecture4/live/live4.py new file mode 100644 index 0000000..b011675 --- /dev/null +++ b/src/Lecture4/live/live4.py | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | |||
| 2 | def fun(a, b): | ||
| 3 | print("This is function fun") | ||
| 4 | print("I am executing!") | ||
| 5 | print("Your parameter a:", a) | ||
| 6 | z = a + b | ||
| 7 | if z > 10: | ||
| 8 | print("Your sum is large!", z) | ||
| 9 | while z > 5: | ||
| 10 | print("Decreasing sum:", z-1) | ||
| 11 | z = z - 1 | ||
| 12 | |||
| 13 | #fun(2, 11) | ||
| 14 | #print("..") | ||
| 15 | #fun(0, 7) | ||
| 16 | |||
| 17 | def g(x, y): | ||
| 18 | #print("This is function g") | ||
| 19 | return (x**2 +1)*y | ||
| 20 | |||
| 21 | print(g(10,2)-100) | ||
| 22 | |||
| 23 | |||
| 24 | def fibo(n): | ||
| 25 | if n == 0: | ||
| 26 | return 0 | ||
| 27 | if n == 1: | ||
| 28 | return 1 | ||
| 29 | return fibo(n-1) + fibo(n-2) | ||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | print(fibo(5)) | ||
| 34 | F = [fibo(x) for x in range(6)] | ||
| 35 | print(F) | ||
| 36 | |||
| 37 | |||
| 38 | |||
| 39 | |||
diff --git a/src/Lecture4/live/live_interactive.py b/src/Lecture4/live/live_interactive.py new file mode 100644 index 0000000..671cbad --- /dev/null +++ b/src/Lecture4/live/live_interactive.py | |||
| @@ -0,0 +1,172 @@ | |||
| 1 | 2+2 | ||
| 2 | 3*5 | ||
| 3 | 3/5 | ||
| 4 | 3 // 5 | ||
| 5 | 2.5 + (456 - 0.3) | ||
| 6 | 2 ** 10 | ||
| 7 | 13 // 5 | ||
| 8 | 13 % 5 | ||
| 9 | sqrt(3) | ||
| 10 | import math | ||
| 11 | sqrt(3) | ||
| 12 | math.sqrt(3) | ||
| 13 | help() | ||
| 14 | math | ||
| 15 | asfdads | ||
| 16 | 2+2 | ||
| 17 | help("import") | ||
| 18 | sqrt(10) | ||
| 19 | math.sqrt(10) | ||
| 20 | from math import * | ||
| 21 | sqrt(10) | ||
| 22 | 10 - _ | ||
| 23 | _ | ||
| 24 | x = 10 + sqrt(3) | ||
| 25 | x | ||
| 26 | abc_3 = 45+3*(2-1.4) | ||
| 27 | abc_3 | ||
| 28 | x / (abc_3+2) | ||
| 29 | x | ||
| 30 | x = 3*abc_3 | ||
| 31 | x | ||
| 32 | abc_3 = 0 | ||
| 33 | abc_3 | ||
| 34 | x | ||
| 35 | 1 = 1 | ||
| 36 | 1 == 1 | ||
| 37 | 1 == 3 | ||
| 38 | x | ||
| 39 | type(x) | ||
| 40 | abc_3 | ||
| 41 | type(abc_3) | ||
| 42 | type(3/2) | ||
| 43 | type(3/1) | ||
| 44 | 3/1 | ||
| 45 | type(1 == 1) | ||
| 46 | y = False | ||
| 47 | z = (2 == 2) | ||
| 48 | y | ||
| 49 | z | ||
| 50 | type(z) | ||
| 51 | type(y) | ||
| 52 | y and z | ||
| 53 | True and True | ||
| 54 | y or z | ||
| 55 | not True | ||
| 56 | 3 >= 4 | ||
| 57 | 3 >= 3 | ||
| 58 | 3 > 3 | ||
| 59 | 3 != 4 | ||
| 60 | hello | ||
| 61 | "hello" | ||
| 62 | type("hello") | ||
| 63 | st = "Hello, World!" | ||
| 64 | st | ||
| 65 | type(st) | ||
| 66 | len(st) | ||
| 67 | "hello" + ", world" | ||
| 68 | "abc" + "abc" | ||
| 69 | 2 * "abc" | ||
| 70 | 10 * "abc" | ||
| 71 | "hello" * "abc" | ||
| 72 | True + False | ||
| 73 | [1,2,3,1,-1.5] | ||
| 74 | [1,True,"hello"] | ||
| 75 | L = [1,True,"hello"] | ||
| 76 | type(L) | ||
| 77 | {1,2,3,1,-1.5} | ||
| 78 | {12, 25, 10, -1} | ||
| 79 | len(L) | ||
| 80 | len({1,1,1}) | ||
| 81 | {1,1,1} | ||
| 82 | 1 in L | ||
| 83 | -42 in L | ||
| 84 | 1.5 in {2,3.1,1.5} | ||
| 85 | S = {-2, 0, 10, 25} | ||
| 86 | max(S) | ||
| 87 | min(S) | ||
| 88 | sum(S) | ||
| 89 | sum([10,2,45]) | ||
| 90 | L | ||
| 91 | min(L) | ||
| 92 | L2 = [1,2, 1, -2, 0, 2] | ||
| 93 | set(L2) | ||
| 94 | list({1,2,1,3,-2}) | ||
| 95 | S | ||
| 96 | list(S) | ||
| 97 | [x**2 for x in [-1,4,1,0] if x < 3] | ||
| 98 | {x**2 for x in [-1,4,1,0] if x < 3} | ||
| 99 | {x+2 for x in [-1,4,1,0] if x < 3} | ||
| 100 | {x+2 for x in {-1,4,1,0} if x < 3} | ||
| 101 | [x+2 for x in {-1,4,1,0} if x < 3] | ||
| 102 | [x+2 for x in {-1,4,1,0} if True] | ||
| 103 | [x+2 for x in {-1,4,1,0}] | ||
| 104 | [x+2 for x in {-1,4,1,0} if x+10-3.24 < x^2] | ||
| 105 | [i*j for i in [0,1,2,3] for j in {-1,1}] | ||
| 106 | range(0,4) | ||
| 107 | type(range(0,4)) | ||
| 108 | [i*j for i in range(0,4) for j in {-1,1}] | ||
| 109 | list(range(0,4)) | ||
| 110 | list(range(3,4)) | ||
| 111 | list(range(3,10)) | ||
| 112 | list(range(10)) | ||
| 113 | list(range(1,10,2)) | ||
| 114 | list(range(10,1,-1)) | ||
| 115 | L | ||
| 116 | L[0] | ||
| 117 | L[1] | ||
| 118 | L[2] | ||
| 119 | L[10] | ||
| 120 | L[-1] | ||
| 121 | L[len(L)-1] | ||
| 122 | L[len(L)-3] | ||
| 123 | L[-3] | ||
| 124 | L2 | ||
| 125 | L[1:4] | ||
| 126 | L2[1:4] | ||
| 127 | L2[1:4:2] | ||
| 128 | R=range(10) | ||
| 129 | R | ||
| 130 | R=list(range(10)) | ||
| 131 | R | ||
| 132 | R[2:8:2] | ||
| 133 | R[9:3:-1] | ||
| 134 | R | ||
| 135 | type(R) | ||
| 136 | R[3] | ||
| 137 | R[3] = 3.14 | ||
| 138 | R | ||
| 139 | R.append(10) | ||
| 140 | R | ||
| 141 | R.insert(3,3.0) | ||
| 142 | R | ||
| 143 | R[3] | ||
| 144 | del R[4] | ||
| 145 | R | ||
| 146 | L | ||
| 147 | R | ||
| 148 | L + R | ||
| 149 | L | ||
| 150 | R | ||
| 151 | L * 3 | ||
| 152 | 3 * L | ||
| 153 | S | ||
| 154 | type(S) | ||
| 155 | S.add(3) | ||
| 156 | S | ||
| 157 | S.add(10) | ||
| 158 | S | ||
| 159 | S.remove(25) | ||
| 160 | S | ||
| 161 | T = {3, -2, 27, 99} | ||
| 162 | {3, -2} < T | ||
| 163 | {3, -2} < S | ||
| 164 | S >= {3, -2} | ||
| 165 | S >= S | ||
| 166 | S > S | ||
| 167 | S | T | ||
| 168 | S & T | ||
| 169 | S - T | ||
| 170 | 2+3 | ||
| 171 | import readline | ||
| 172 | readline.write_history_file('live_interactive.py') | ||
