Skip to content

Commit 3c40743

Browse files
authored
Merge pull request #7 from Code-by-practice/develop
Develop
2 parents 7c7a56b + 35db9df commit 3c40743

File tree

11 files changed

+154
-91
lines changed

11 files changed

+154
-91
lines changed

codes/ch1_syntax/eg1_helloworld.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

codes/ch1_syntax/eg2_comments.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

codes/ch1_syntax/eg3_main.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

codes/ch1_syntax/eg4_whitespace.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

codes/ch1_syntax/eg5_assignment.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

codes/ch1_syntax/eg6_conditional.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

codes/ch1_syntax/eg7_function.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

codes/ch1_syntax/eg8_objects.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

codes/session_1/list.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Open terminal > python3
2+
# Start typing below commands and see the output
3+
4+
a = [10, 20, 30, 40, 50]
5+
a # [10, 20, 30, 40, 50]
6+
a[0] # 10
7+
a[3] # 40
8+
a[-1] # 50
9+
a[0:3] # [10, 20, 30]
10+
a[3:5] # [40, 50]
11+
a[3:] # [40, 50]
12+
a[:2] # [10, 20]
13+
a[-2:] # [40, 50]
14+
a[:-2] # [10, 20, 30]
15+
16+
a + [60, 70, 80, 90, 100]
17+
18+
a[2] = 300
19+
a # [10, 20, 300, 40, 50]
20+
21+
a.append(250)
22+
a # [10, 20, 300, 40, 50, 250]
23+
24+
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
25+
letters
26+
27+
# Replace some value in letters list
28+
letters[2:4] = ['C', 'D', 'E']
29+
letters # ['a', 'b', 'C', 'D', 'E', 'e', 'f', 'g']
30+
31+
# Remove them
32+
letters[2:4] = []
33+
letters
34+
35+
# Clear list
36+
letters[:] = []
37+
letters # []
38+
39+
# Nested list
40+
a = [1, 2, 3]
41+
b = [4, 5, 6]
42+
x = [a, b]
43+
x # [[1, 2, 3], [4, 5, 6]]
44+
x[0] # [1, 2, 3]
45+
x[0][1] # 2
46+
47+
48+
49+
50+
51+

codes/session_1/numbers.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Open terminal > python3
2+
# Start typing below commands and see the output
3+
4+
2 + 2
5+
45 - 5
6+
7+
# Division always returns a floating point number
8+
45 / 5
9+
10+
# To avoid floating in division
11+
45 // 5
12+
13+
17 % 2
14+
15+
5 * 2
16+
17+
5 ** 2 # 5 square, 5 to the power of 2
18+
19+
width = 45
20+
height = 45
21+
width * height
22+
23+
# List printed expression is assign to `_`
24+
a = 100
25+
b = 200
26+
c = 250
27+
28+
a + b # 300
29+
c + _ # 550 (250 + 300)
30+
31+
32+
33+
34+
35+
36+
37+
38+

0 commit comments

Comments
 (0)