aboutsummaryrefslogtreecommitdiff
path: root/src/Lecture4/live
diff options
context:
space:
mode:
Diffstat (limited to 'src/Lecture4/live')
-rw-r--r--src/Lecture4/live/live.zipbin0 -> 2264 bytes
-rw-r--r--src/Lecture4/live/live1.py17
-rw-r--r--src/Lecture4/live/live2.py7
-rw-r--r--src/Lecture4/live/live3.py9
-rw-r--r--src/Lecture4/live/live4.py39
-rw-r--r--src/Lecture4/live/live_interactive.py172
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 @@
1print(2+2)
2
3x = input("Input something: ")
4print("Your input was:", x, "of type", type(x))
5
6x_number = int(x)
7print("Converted to a number:", x_number, "of type", type(x_number))
8
9if 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)
14else:
15 print("Your number was small")
16
17print("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 @@
1x = int(input("Input something: "))
2
3while x > 10:
4 print("Large number!", x)
5 x = x - 1
6
7print("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 @@
1x = int(input("Input something: "))
2
3A = [1,2,3]
4
5for i in range(2,9):
6 z = 10**i
7 print("A power of 10:", z)
8
9print("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
2def 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
17def g(x, y):
18 #print("This is function g")
19 return (x**2 +1)*y
20
21print(g(10,2)-100)
22
23
24def 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
33print(fibo(5))
34F = [fibo(x) for x in range(6)]
35print(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 @@
12+2
23*5
33/5
43 // 5
52.5 + (456 - 0.3)
62 ** 10
713 // 5
813 % 5
9sqrt(3)
10import math
11sqrt(3)
12math.sqrt(3)
13help()
14math
15asfdads
162+2
17help("import")
18sqrt(10)
19math.sqrt(10)
20from math import *
21sqrt(10)
2210 - _
23_
24x = 10 + sqrt(3)
25x
26abc_3 = 45+3*(2-1.4)
27abc_3
28x / (abc_3+2)
29x
30x = 3*abc_3
31x
32abc_3 = 0
33abc_3
34x
351 = 1
361 == 1
371 == 3
38x
39type(x)
40abc_3
41type(abc_3)
42type(3/2)
43type(3/1)
443/1
45type(1 == 1)
46y = False
47z = (2 == 2)
48y
49z
50type(z)
51type(y)
52y and z
53True and True
54y or z
55not True
563 >= 4
573 >= 3
583 > 3
593 != 4
60hello
61"hello"
62type("hello")
63st = "Hello, World!"
64st
65type(st)
66len(st)
67"hello" + ", world"
68"abc" + "abc"
692 * "abc"
7010 * "abc"
71"hello" * "abc"
72True + False
73[1,2,3,1,-1.5]
74[1,True,"hello"]
75L = [1,True,"hello"]
76type(L)
77{1,2,3,1,-1.5}
78{12, 25, 10, -1}
79len(L)
80len({1,1,1})
81{1,1,1}
821 in L
83-42 in L
841.5 in {2,3.1,1.5}
85S = {-2, 0, 10, 25}
86max(S)
87min(S)
88sum(S)
89sum([10,2,45])
90L
91min(L)
92L2 = [1,2, 1, -2, 0, 2]
93set(L2)
94list({1,2,1,3,-2})
95S
96list(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}]
106range(0,4)
107type(range(0,4))
108[i*j for i in range(0,4) for j in {-1,1}]
109list(range(0,4))
110list(range(3,4))
111list(range(3,10))
112list(range(10))
113list(range(1,10,2))
114list(range(10,1,-1))
115L
116L[0]
117L[1]
118L[2]
119L[10]
120L[-1]
121L[len(L)-1]
122L[len(L)-3]
123L[-3]
124L2
125L[1:4]
126L2[1:4]
127L2[1:4:2]
128R=range(10)
129R
130R=list(range(10))
131R
132R[2:8:2]
133R[9:3:-1]
134R
135type(R)
136R[3]
137R[3] = 3.14
138R
139R.append(10)
140R
141R.insert(3,3.0)
142R
143R[3]
144del R[4]
145R
146L
147R
148L + R
149L
150R
151L * 3
1523 * L
153S
154type(S)
155S.add(3)
156S
157S.add(10)
158S
159S.remove(25)
160S
161T = {3, -2, 27, 99}
162{3, -2} < T
163{3, -2} < S
164S >= {3, -2}
165S >= S
166S > S
167S | T
168S & T
169S - T
1702+3
171import readline
172readline.write_history_file('live_interactive.py')

Generated with cgit - Back to sebastiano.tronto.net