WEBVTT

1
00:00:00.040 --> 00:00:02.520
<v Speaker 1>Welcome back to the deep dive. Today. We're getting into

2
00:00:02.560 --> 00:00:05.839
<v Speaker 1>the foundations, specifically Python three programming.

3
00:00:06.080 --> 00:00:09.240
<v Speaker 2>That's right, and we're basing this on some really solid

4
00:00:09.359 --> 00:00:13.359
<v Speaker 2>material excerpts from a Beginner's Guide, part of the Undergraduate

5
00:00:13.400 --> 00:00:17.280
<v Speaker 2>Topics and Computer Science series, peer reviewed expert.

6
00:00:16.839 --> 00:00:19.839
<v Speaker 1>Author right, and the book itself is aimed at people

7
00:00:20.239 --> 00:00:24.519
<v Speaker 1>starting from scratch, maybe zero programming knowledge, but wants to

8
00:00:24.559 --> 00:00:28.879
<v Speaker 1>get them up to speed as capable Python developers exactly.

9
00:00:29.199 --> 00:00:31.160
<v Speaker 2>So our goal here is to kind of pull out

10
00:00:31.160 --> 00:00:35.479
<v Speaker 2>the key takeaways, give you that shortcut to the core

11
00:00:35.560 --> 00:00:36.759
<v Speaker 2>ideas of Python.

12
00:00:36.439 --> 00:00:38.759
<v Speaker 1>Three, distilled version from a trusted source.

13
00:00:38.560 --> 00:00:41.200
<v Speaker 2>Precisely getting the best bits without reading the whole thing

14
00:00:41.240 --> 00:00:41.799
<v Speaker 2>cover to cover.

15
00:00:42.039 --> 00:00:45.479
<v Speaker 1>Okay, let's jump right in Python itself. Is it fundamentally

16
00:00:45.520 --> 00:00:47.640
<v Speaker 1>and maybe what's a key thing that sets it apart

17
00:00:47.719 --> 00:00:48.200
<v Speaker 1>early on?

18
00:00:48.679 --> 00:00:51.439
<v Speaker 2>Sure? Well, at its heart it's a general purpose language.

19
00:00:51.439 --> 00:00:54.439
<v Speaker 2>You hear it alongside CE plus plus T, JavaScript, Java,

20
00:00:54.520 --> 00:00:58.039
<v Speaker 2>that kind of thing, and a really defining characteristic the

21
00:00:58.079 --> 00:01:00.960
<v Speaker 2>book flags immediately is dynamic typing.

22
00:01:01.119 --> 00:01:03.960
<v Speaker 1>Dynamic typing, okay, so that means a variable isn't locked

23
00:01:03.960 --> 00:01:05.359
<v Speaker 1>into one data type.

24
00:01:05.400 --> 00:01:08.799
<v Speaker 2>Exactly, that you can have a variable holding say a number,

25
00:01:09.200 --> 00:01:11.599
<v Speaker 2>and then later on you can assign text a string

26
00:01:12.000 --> 00:01:13.560
<v Speaker 2>to that same variable name.

27
00:01:13.799 --> 00:01:17.359
<v Speaker 1>Python's fine with it, uh huh, unlike say Java or

28
00:01:17.400 --> 00:01:19.680
<v Speaker 1>c sharp, where you declare the type up front and

29
00:01:19.719 --> 00:01:20.359
<v Speaker 1>it's fixed.

30
00:01:20.640 --> 00:01:23.079
<v Speaker 2>Right. That adds a lot of flexibility, which is a

31
00:01:23.120 --> 00:01:24.319
<v Speaker 2>big part of Python's appeal.

32
00:01:24.519 --> 00:01:30.400
<v Speaker 1>Interesting and the name Python it's not about snakes, h No.

33
00:01:30.319 --> 00:01:32.799
<v Speaker 2>Not directly. It was created back in the eighties by

34
00:01:32.879 --> 00:01:35.879
<v Speaker 2>Guido van Rossum in the Netherlands. Yeah, and he named

35
00:01:35.920 --> 00:01:38.840
<v Speaker 2>it after Monty Python's flying Circus big fan.

36
00:01:39.200 --> 00:01:40.799
<v Speaker 1>Seriously, that's brilliant.

37
00:01:40.879 --> 00:01:43.359
<v Speaker 2>Yeah, and the book mentions you'll even find little nods

38
00:01:43.359 --> 00:01:46.719
<v Speaker 2>to the show in Python's official documentation sometimes.

39
00:01:46.840 --> 00:01:48.879
<v Speaker 1>Love that bit of personality definitely.

40
00:01:49.239 --> 00:01:51.560
<v Speaker 2>And yeah, just to confirm we are laser focused on

41
00:01:51.640 --> 00:01:53.359
<v Speaker 2>Python three here as that's what the.

42
00:01:53.280 --> 00:01:57.200
<v Speaker 1>Source covers got it now. The book brings up programming paradigms,

43
00:01:57.239 --> 00:01:59.439
<v Speaker 1>different ways to structure code. It starts with.

44
00:02:00.560 --> 00:02:03.599
<v Speaker 2>Right, Procedural programming is sort of the classic approach. Think

45
00:02:03.640 --> 00:02:07.000
<v Speaker 2>of it like a recipe, a sequence of explicit instructions.

46
00:02:07.439 --> 00:02:10.599
<v Speaker 2>You break the steps down into procedures or functions and

47
00:02:10.759 --> 00:02:14.120
<v Speaker 2>use things like if statements and loops to control the flow.

48
00:02:14.280 --> 00:02:15.960
<v Speaker 1>Like see your Pascal exactly.

49
00:02:16.039 --> 00:02:18.599
<v Speaker 2>Those are prime examples. It's a good starting point to

50
00:02:18.680 --> 00:02:21.360
<v Speaker 2>understand how programs can be organized before we maybe get

51
00:02:21.360 --> 00:02:24.680
<v Speaker 2>into other styles later like functional or object oriented.

52
00:02:24.800 --> 00:02:28.479
<v Speaker 1>Makes sense, but okay, before writing any code, you need

53
00:02:28.520 --> 00:02:31.080
<v Speaker 1>the tools. Setting up the environment.

54
00:02:30.759 --> 00:02:34.479
<v Speaker 2>Yep, fundamental step. The book recommends the most direct route

55
00:02:34.759 --> 00:02:37.639
<v Speaker 2>go to the official Python website Python dot org. Python

56
00:02:37.680 --> 00:02:40.439
<v Speaker 2>dot org, I find the downloads link, grab the installer

57
00:02:40.479 --> 00:02:43.639
<v Speaker 2>for your system, Windows, Mac, Linux, They're all.

58
00:02:43.479 --> 00:02:46.080
<v Speaker 1>There, and part of installing is making sure your computer

59
00:02:46.120 --> 00:02:48.759
<v Speaker 1>can find Python right. The path variable thing.

60
00:02:48.759 --> 00:02:52.080
<v Speaker 2>Crucial point, especially on Windows. You need Python on your

61
00:02:52.120 --> 00:02:54.599
<v Speaker 2>system's path, so you can just open a terminal or

62
00:02:54.639 --> 00:02:57.120
<v Speaker 2>command prompt type Python and it works.

63
00:02:56.960 --> 00:02:59.240
<v Speaker 1>Right, so it's accessible from anywhere exactly.

64
00:02:59.639 --> 00:03:02.840
<v Speaker 2>The book also really pushes using a good code editor

65
00:03:03.240 --> 00:03:08.039
<v Speaker 2>or even better, an ID an integrated development environment.

66
00:03:07.719 --> 00:03:10.039
<v Speaker 1>So something more than just basic notepad.

67
00:03:10.360 --> 00:03:14.120
<v Speaker 2>Definitely. It mentions Sublime text as a good text editor

68
00:03:14.159 --> 00:03:17.759
<v Speaker 2>to start with. It understands Python syntax does color coding

69
00:03:17.960 --> 00:03:20.840
<v Speaker 2>makes things much easier to read, okay, but for more

70
00:03:20.879 --> 00:03:25.800
<v Speaker 2>involved projects. It flags a full ID as being really beneficial.

71
00:03:25.479 --> 00:03:27.680
<v Speaker 1>And the recommendation there is pie Charm PI.

72
00:03:27.680 --> 00:03:31.120
<v Speaker 2>Charm from Jet Brains. Yeah, it's described as a full workbench.

73
00:03:31.400 --> 00:03:35.719
<v Speaker 2>It has code completion, debugging tools, integrated version control like get,

74
00:03:36.039 --> 00:03:38.560
<v Speaker 2>lots of features that become really helpful as you progress.

75
00:03:38.680 --> 00:03:41.719
<v Speaker 1>Jet Brain's website for that one, and the example code

76
00:03:41.719 --> 00:03:42.680
<v Speaker 1>from the book itself.

77
00:03:42.759 --> 00:03:45.400
<v Speaker 2>Two main ways suggested. If you've got GET installed, you

78
00:03:45.400 --> 00:03:47.800
<v Speaker 2>can just use get clone with the GitHub link provided

79
00:03:47.800 --> 00:03:49.360
<v Speaker 2>in the book, or if you don't have get, then

80
00:03:49.400 --> 00:03:50.960
<v Speaker 2>you can usually just download the whole thing as a

81
00:03:51.039 --> 00:03:54.159
<v Speaker 2>ZIP file directly from that same GitHub page. And as

82
00:03:54.199 --> 00:03:56.599
<v Speaker 2>the book knows, IDEs like pie Charm often have Get

83
00:03:56.599 --> 00:03:58.919
<v Speaker 2>built in any way, which makes cloning easier.

84
00:03:59.000 --> 00:04:04.360
<v Speaker 1>Okay, environments now the traditional first program Hello World, the classic.

85
00:04:04.520 --> 00:04:07.039
<v Speaker 2>It's really just a sanity check, you know, does the

86
00:04:07.039 --> 00:04:10.639
<v Speaker 2>interpreter run? Does my editor save the file correctly? Are

87
00:04:10.680 --> 00:04:11.479
<v Speaker 2>the settings okay?

88
00:04:11.560 --> 00:04:14.479
<v Speaker 1>And Python files usually have the dot pi extension correct.

89
00:04:14.560 --> 00:04:17.240
<v Speaker 2>Dot PI is the standard and the key piece of

90
00:04:17.279 --> 00:04:21.040
<v Speaker 2>code for Hello World is the print function that's.

91
00:04:20.839 --> 00:04:22.800
<v Speaker 1>Built in part of Python itself.

92
00:04:22.920 --> 00:04:26.600
<v Speaker 2>Yep, a fundamental built in function. It's how you tell

93
00:04:26.639 --> 00:04:29.000
<v Speaker 2>your program to display output on the screen.

94
00:04:29.439 --> 00:04:32.639
<v Speaker 1>Then the book makes it interactive pretty quickly with input.

95
00:04:32.519 --> 00:04:36.160
<v Speaker 2>Right flips the script dot input. Let's the program ask you,

96
00:04:36.360 --> 00:04:38.879
<v Speaker 2>the user, a question, it shows a prompt.

97
00:04:38.560 --> 00:04:40.160
<v Speaker 1>Message whatever text you give it.

98
00:04:40.120 --> 00:04:42.319
<v Speaker 2>Exactly, then a weads for you to type something and

99
00:04:42.399 --> 00:04:45.839
<v Speaker 2>press enter. Whatever you typed comes back into the program

100
00:04:46.040 --> 00:04:47.720
<v Speaker 2>as a string as text.

101
00:04:47.480 --> 00:04:50.199
<v Speaker 1>Data, which means you need somewhere to store that input

102
00:04:50.720 --> 00:04:52.000
<v Speaker 1>enter variables.

103
00:04:51.720 --> 00:04:55.120
<v Speaker 2>Perfect lead in variables are essentially named storage spots in

104
00:04:55.160 --> 00:04:57.839
<v Speaker 2>the computer's memory. You give a piece of data a name,

105
00:04:58.040 --> 00:04:59.480
<v Speaker 2>a label so you can refer to it.

106
00:04:59.519 --> 00:05:02.720
<v Speaker 1>Later username in the example exactly.

107
00:05:02.519 --> 00:05:06.319
<v Speaker 2>And dining back to dynamic typing, that username variable holds

108
00:05:06.360 --> 00:05:09.079
<v Speaker 2>the string from the input function, but you could theoretically

109
00:05:09.120 --> 00:05:11.439
<v Speaker 2>assign a number to username later if you want it.

110
00:05:11.639 --> 00:05:16.480
<v Speaker 1>So the sequence print Hello World, then username input under

111
00:05:16.519 --> 00:05:19.000
<v Speaker 1>your name using the equals sign.

112
00:05:19.199 --> 00:05:21.879
<v Speaker 2>The assignment operator right assigns the result of the input

113
00:05:21.959 --> 00:05:24.480
<v Speaker 2>function to the variable username, and.

114
00:05:24.439 --> 00:05:28.839
<v Speaker 1>Then print hello username. That shows print can handle multiple things.

115
00:05:28.920 --> 00:05:32.680
<v Speaker 2>Yeah, you can give print multiple arguments separated by commas,

116
00:05:33.079 --> 00:05:36.439
<v Speaker 2>like the literal text hello and the value stored in

117
00:05:36.480 --> 00:05:39.199
<v Speaker 2>the username variable. It prints them out, usually with a

118
00:05:39.240 --> 00:05:42.480
<v Speaker 2>space in between by default. A neat little demonstration.

119
00:05:42.040 --> 00:05:45.839
<v Speaker 1>Simple but covers input, output, variables, assignment. Nice.

120
00:05:46.000 --> 00:05:47.600
<v Speaker 2>It's those core building blocks.

121
00:05:47.360 --> 00:05:49.439
<v Speaker 1>Okay, let's talk more about those building blocks, the basic

122
00:05:49.519 --> 00:05:50.079
<v Speaker 1>data types.

123
00:05:50.160 --> 00:05:53.920
<v Speaker 2>The source focuses on four key ones to start strings,

124
00:05:54.160 --> 00:05:58.759
<v Speaker 2>text numbers, integers and floating point Boollian's true false, and

125
00:05:58.800 --> 00:05:59.959
<v Speaker 2>this special value none.

126
00:06:00.160 --> 00:06:02.639
<v Speaker 1>Strings first, text inside quotes yep.

127
00:06:02.959 --> 00:06:06.199
<v Speaker 2>Single quotes like this or double quotes like this functionally

128
00:06:06.240 --> 00:06:09.480
<v Speaker 2>identical in Python. The book mentioned single quotes are maybe

129
00:06:09.560 --> 00:06:12.879
<v Speaker 2>slightly more common sort of the Pythonic convention, but both

130
00:06:12.920 --> 00:06:13.480
<v Speaker 2>work fine.

131
00:06:13.720 --> 00:06:17.639
<v Speaker 1>And strings aren't just static texts. They have operations methods.

132
00:06:17.920 --> 00:06:20.279
<v Speaker 2>Oh yeah, lots of useful built in methods, things like

133
00:06:20.519 --> 00:06:23.000
<v Speaker 2>split to break a string into a list of words,

134
00:06:23.000 --> 00:06:25.040
<v Speaker 2>starts with or ends with to check.

135
00:06:24.920 --> 00:06:27.120
<v Speaker 1>The beginning or end case checking two dot I supper

136
00:06:27.199 --> 00:06:28.360
<v Speaker 1>eyes lower.

137
00:06:28.319 --> 00:06:31.079
<v Speaker 2>Or dot isselfa to see if it's all letters. Very

138
00:06:31.120 --> 00:06:34.040
<v Speaker 2>handy stuff, and case matters in comparisons.

139
00:06:34.120 --> 00:06:36.560
<v Speaker 1>So Python is different from Python absolutely.

140
00:06:36.920 --> 00:06:39.800
<v Speaker 2>If you want to compare strings regardless of case, the

141
00:06:39.920 --> 00:06:42.560
<v Speaker 2>usual trick is to convert both to lower case first

142
00:06:43.000 --> 00:06:48.079
<v Speaker 2>using dot lower so misstring dot lower Hello. Method names

143
00:06:48.120 --> 00:06:49.639
<v Speaker 2>are also case sensitive, naturally.

144
00:06:49.800 --> 00:06:52.600
<v Speaker 1>The book also mentions a way to format strings using

145
00:06:52.680 --> 00:06:53.759
<v Speaker 1>string dot template.

146
00:06:54.000 --> 00:06:57.000
<v Speaker 2>Yeah, that's one method. You create a template with placeholders

147
00:06:57.199 --> 00:06:59.920
<v Speaker 2>like two hood and then use the dot substitute method

148
00:07:00.040 --> 00:07:03.360
<v Speaker 2>to fill in those placeholders with actual values. There's also

149
00:07:03.439 --> 00:07:06.360
<v Speaker 2>dot save substitute, which is useful because it won't raise

150
00:07:06.360 --> 00:07:08.120
<v Speaker 2>an error if you forget to provide a value for

151
00:07:08.160 --> 00:07:10.519
<v Speaker 2>a placeholder, It just leaves the placeholder texts.

152
00:07:10.639 --> 00:07:13.920
<v Speaker 1>As is, moving on to numbers, integers and floats.

153
00:07:14.079 --> 00:07:17.360
<v Speaker 2>Integers are whole numbers like ten naked five zero zero.

154
00:07:17.759 --> 00:07:20.160
<v Speaker 2>Floats are numbers with a decimal point like three point

155
00:07:20.160 --> 00:07:23.319
<v Speaker 2>one four next zero point five. Python uses a standard

156
00:07:23.319 --> 00:07:26.079
<v Speaker 2>format called i EEE seven five to four for.

157
00:07:26.079 --> 00:07:28.160
<v Speaker 1>Floats, and you can convert between them.

158
00:07:28.079 --> 00:07:31.759
<v Speaker 2>Yes, using the end and float functions in three point

159
00:07:31.839 --> 00:07:34.279
<v Speaker 2>nine O three boards. It truncates, just chops off the

160
00:07:34.319 --> 00:07:37.160
<v Speaker 2>decimal part, doesn't round. Float five gives five point.

161
00:07:37.000 --> 00:07:40.160
<v Speaker 1>Zero arithmetic a standard plus heat division.

162
00:07:40.199 --> 00:07:44.199
<v Speaker 2>Okay, division's interesting. The single slash always results in a slot.

163
00:07:44.319 --> 00:07:46.040
<v Speaker 2>Even four to two gives two point zero always a

164
00:07:46.040 --> 00:07:49.439
<v Speaker 2>float always if you specifically want integer division the whole

165
00:07:49.519 --> 00:07:52.319
<v Speaker 2>number result, throwing away any remainder you use the double

166
00:07:52.360 --> 00:07:54.279
<v Speaker 2>slash move. So five two is two got it.

167
00:07:54.560 --> 00:07:56.560
<v Speaker 1>For float division? For integer division, and.

168
00:07:56.519 --> 00:07:59.000
<v Speaker 2>If you mix types like adding an integer in a float,

169
00:07:59.040 --> 00:08:01.720
<v Speaker 2>the result will always be promoted to a float makes sense.

170
00:08:01.959 --> 00:08:03.399
<v Speaker 1>Boolean's next true and.

171
00:08:03.360 --> 00:08:07.079
<v Speaker 2>False the bedrock of decision making capital T capital F.

172
00:08:08.079 --> 00:08:10.879
<v Speaker 2>The book points out a slightly quirky detail. Technically, there

173
00:08:10.920 --> 00:08:14.040
<v Speaker 2>are subtype of integers really and true is one and

174
00:08:14.240 --> 00:08:17.600
<v Speaker 2>false as zero, and conversely boole one is true, zero,

175
00:08:18.160 --> 00:08:21.879
<v Speaker 2>zero is false. Non zero numbers are generally true, zero.

176
00:08:21.680 --> 00:08:25.079
<v Speaker 1>Is false interesting connection, and the last one. None.

177
00:08:25.240 --> 00:08:28.160
<v Speaker 2>None is Python's special way to signify the absence of

178
00:08:28.160 --> 00:08:30.360
<v Speaker 2>a value. It's not zero, it's not an empty straying,

179
00:08:30.480 --> 00:08:34.320
<v Speaker 2>it's just nothing. It has its own unique type none type.

180
00:08:34.440 --> 00:08:35.320
<v Speaker 1>When would you use it?

181
00:08:35.559 --> 00:08:38.399
<v Speaker 2>Often is a default value, or maybe a function returns

182
00:08:39.360 --> 00:08:41.679
<v Speaker 2>none if it couldn't compute a result for some reason.

183
00:08:41.440 --> 00:08:43.799
<v Speaker 1>And checking for it. The book says, use is none.

184
00:08:43.639 --> 00:08:46.440
<v Speaker 2>Yes, variable is none, or variable is not none. That's

185
00:08:46.480 --> 00:08:49.399
<v Speaker 2>the preferred, most reliable way to check if something holds

186
00:08:49.440 --> 00:08:53.360
<v Speaker 2>the none value. Using none can sometimes work, but is

187
00:08:53.399 --> 00:08:54.799
<v Speaker 2>safer and more idiomatic.

188
00:08:54.879 --> 00:08:58.200
<v Speaker 1>Okay, data typees covered now. Making the program do things

189
00:08:58.240 --> 00:09:02.039
<v Speaker 1>based on conditions or repeat actions control flow if statements first.

190
00:09:02.039 --> 00:09:06.200
<v Speaker 2>Right, the fundamental decision maker if condition. If that condition

191
00:09:06.240 --> 00:09:10.039
<v Speaker 2>evaluates too true, the indented block of code underneath it runs.

192
00:09:10.279 --> 00:09:14.159
<v Speaker 1>If not it's skipped, and that indentation is crucial absolutely

193
00:09:14.200 --> 00:09:15.279
<v Speaker 1>non negotiable in Python.

194
00:09:15.399 --> 00:09:18.600
<v Speaker 2>Unlike languages that use curly braces, Python uses white space

195
00:09:19.000 --> 00:09:22.679
<v Speaker 2>the indentation level to define which lines of code belong

196
00:09:22.759 --> 00:09:25.480
<v Speaker 2>to the If block or else or loops or functions

197
00:09:26.080 --> 00:09:28.399
<v Speaker 2>get it wrong, you get errors or incorrect logic.

198
00:09:28.480 --> 00:09:30.279
<v Speaker 1>The standard is four spaces four.

199
00:09:30.159 --> 00:09:32.559
<v Speaker 2>Spaces per indentation level is the strong convention.

200
00:09:32.679 --> 00:09:36.440
<v Speaker 1>Yeah, okay, So if block runs code if true, what

201
00:09:36.600 --> 00:09:37.399
<v Speaker 1>if it's fault?

202
00:09:37.480 --> 00:09:39.559
<v Speaker 2>That's where else comes in ye if condition total one

203
00:09:39.600 --> 00:09:41.799
<v Speaker 2>block runs if true, the other runs if.

204
00:09:41.679 --> 00:09:44.279
<v Speaker 1>False, and for more than two options you use.

205
00:09:44.279 --> 00:09:46.840
<v Speaker 2>Lf sure for else. If if condition one, l if

206
00:09:47.120 --> 00:09:50.120
<v Speaker 2>condition two, l's condition three, I guess. Python checks each

207
00:09:50.120 --> 00:09:52.840
<v Speaker 2>condition in order. The first one that's true gets executed,

208
00:09:53.000 --> 00:09:55.200
<v Speaker 2>and the rest, including the final else, are skipped.

209
00:09:55.360 --> 00:09:58.519
<v Speaker 1>Can you put if statements inside other if statements?

210
00:09:58.600 --> 00:10:01.399
<v Speaker 2>Sure? That's called nesting really valid, though deep nesting can

211
00:10:01.440 --> 00:10:04.399
<v Speaker 2>sometimes make code harder to read. The book also briefly

212
00:10:04.440 --> 00:10:05.720
<v Speaker 2>mentions if expressions.

213
00:10:06.000 --> 00:10:06.679
<v Speaker 1>What are those?

214
00:10:07.080 --> 00:10:11.279
<v Speaker 2>It's like a compressed ifels that produces a value often

215
00:10:11.360 --> 00:10:14.639
<v Speaker 2>used directly in assignments like result is value a true

216
00:10:14.679 --> 00:10:18.240
<v Speaker 2>if condition else value a false it's a neat shorthand

217
00:10:18.240 --> 00:10:19.080
<v Speaker 2>for simple cases.

218
00:10:19.440 --> 00:10:23.159
<v Speaker 1>Okay, decisions covered. What about repetition loops.

219
00:10:22.919 --> 00:10:27.039
<v Speaker 2>Two main kinds while and four. A while loop keeps

220
00:10:27.080 --> 00:10:31.240
<v Speaker 2>executing its block of code as long as its condition remains.

221
00:10:30.919 --> 00:10:32.919
<v Speaker 1>True, so you need to make sure that the condition

222
00:10:33.000 --> 00:10:34.639
<v Speaker 1>eventually becomes false exactly.

223
00:10:34.639 --> 00:10:37.279
<v Speaker 2>Otherwise you have an infinite loop, and you usually need

224
00:10:37.320 --> 00:10:39.879
<v Speaker 2>to set up the variable used in the condition before

225
00:10:39.919 --> 00:10:42.879
<v Speaker 2>the loop starts. And loops four loops are generally used

226
00:10:42.879 --> 00:10:45.440
<v Speaker 2>when you want to iterate over a sequence of items,

227
00:10:45.480 --> 00:10:47.720
<v Speaker 2>like all the elements in a list, where characters in

228
00:10:47.759 --> 00:10:50.000
<v Speaker 2>a string or specific range of numbers.

229
00:10:50.120 --> 00:10:52.320
<v Speaker 1>Often clearer when you know how many times you need

230
00:10:52.360 --> 00:10:53.120
<v Speaker 1>to loop.

231
00:10:53.000 --> 00:10:55.399
<v Speaker 2>Yeah, or when you're processing each item in a collection.

232
00:10:55.879 --> 00:10:58.759
<v Speaker 2>The structure for item and collection is very common and

233
00:10:58.799 --> 00:10:59.679
<v Speaker 2>readable in Python.

234
00:11:00.120 --> 00:11:03.240
<v Speaker 1>What if your looping, say, searching for something, and you

235
00:11:03.320 --> 00:11:05.399
<v Speaker 1>find it early, can you stop the loop?

236
00:11:05.559 --> 00:11:08.159
<v Speaker 2>Yes, that's what the brake statement is for. It immediately

237
00:11:08.240 --> 00:11:10.919
<v Speaker 2>exits the current innermost while or for loop.

238
00:11:10.960 --> 00:11:14.679
<v Speaker 1>You're in okay, and the book mentions a weird four

239
00:11:14.759 --> 00:11:15.679
<v Speaker 1>else construct.

240
00:11:15.919 --> 00:11:18.960
<v Speaker 2>Ah, yes, the loop else. It's a bit unusual if

241
00:11:18.960 --> 00:11:22.279
<v Speaker 2>you're coming from other languages. An else block attached to

242
00:11:22.320 --> 00:11:25.720
<v Speaker 2>a for loop or while executes only if the loop

243
00:11:25.759 --> 00:11:29.159
<v Speaker 2>completed normally, meaning it went through all its iterations without

244
00:11:29.279 --> 00:11:30.559
<v Speaker 2>encountering a break statement.

245
00:11:30.639 --> 00:11:33.360
<v Speaker 1>So if you break out the else's skipt correct.

246
00:11:33.399 --> 00:11:35.720
<v Speaker 2>It's often used in search loops. If the loop finishes

247
00:11:35.759 --> 00:11:38.840
<v Speaker 2>and the elf block runs, it means the break never happened.

248
00:11:38.879 --> 00:11:40.399
<v Speaker 2>Therefore the item wasn't found.

249
00:11:40.720 --> 00:11:45.039
<v Speaker 1>Huh, that's actually quite clever. Okay. As programs grow, just

250
00:11:45.080 --> 00:11:48.559
<v Speaker 1>having one long sequence of code isn't practical. Functions are

251
00:11:48.600 --> 00:11:49.039
<v Speaker 1>the answer.

252
00:11:49.200 --> 00:11:52.360
<v Speaker 2>Absolutely essential. Functions let you package up a piece of code,

253
00:11:52.480 --> 00:11:54.840
<v Speaker 2>give it a name, and reuse it. They're key to

254
00:11:54.879 --> 00:11:59.759
<v Speaker 2>breaking down large, complex problems into smaller, more manageable, testable units.

255
00:12:00.039 --> 00:12:03.320
<v Speaker 1>BOK connects this to something called functional decomposition.

256
00:12:02.840 --> 00:12:05.600
<v Speaker 2>Right, that's a more formal term from software analysis. It's

257
00:12:05.639 --> 00:12:08.639
<v Speaker 2>the process of identifying the main tasks your system needs

258
00:12:08.639 --> 00:12:12.519
<v Speaker 2>to perform, representing them as functions, and then breaking down

259
00:12:12.559 --> 00:12:16.759
<v Speaker 2>those functions into smaller subfunctions, focusing on inputs, outputs, and

260
00:12:16.799 --> 00:12:18.080
<v Speaker 2>the transformation.

261
00:12:17.559 --> 00:12:21.519
<v Speaker 1>Process and it mentions. Flow charts and data dictionaries alongside.

262
00:12:21.080 --> 00:12:24.879
<v Speaker 2>This, Yeah, as related tools. Flow charts help visualize this

263
00:12:24.960 --> 00:12:28.159
<v Speaker 2>sequence of steps and decisions in an algorithm. While data

264
00:12:28.159 --> 00:12:31.399
<v Speaker 2>dictionaries provide a central place to define and describe all

265
00:12:31.440 --> 00:12:35.480
<v Speaker 2>the data elements your system uses, useful for planning and documentation.

266
00:12:35.960 --> 00:12:38.200
<v Speaker 1>So defining a function in Python starts with.

267
00:12:38.320 --> 00:12:42.320
<v Speaker 2>Death deaf function name, parameters, followed by the colon and

268
00:12:42.399 --> 00:12:45.679
<v Speaker 2>the indented block of code that makes up the function's body. Again,

269
00:12:45.720 --> 00:12:48.559
<v Speaker 2>that four S based enden convention is standard, and the

270
00:12:48.639 --> 00:12:52.480
<v Speaker 2>doc string oh very important for documentation. It's a string

271
00:12:52.759 --> 00:12:55.240
<v Speaker 2>literal place right at the beginning of the function body

272
00:12:55.320 --> 00:12:58.480
<v Speaker 2>inside cripple quotes. Usually it explains what the function does,

273
00:12:58.559 --> 00:13:00.639
<v Speaker 2>what its parameters are, what a return, urns, et cetera.

274
00:13:01.000 --> 00:13:04.720
<v Speaker 2>It's not just a comment. Tools can automatically extract this information.

275
00:13:05.039 --> 00:13:07.919
<v Speaker 1>Parameters are in the definition. Arguments are what you pass

276
00:13:07.960 --> 00:13:08.559
<v Speaker 1>when you call it.

277
00:13:08.879 --> 00:13:13.240
<v Speaker 2>Correct parameters are the names used inside the function. Arguments

278
00:13:13.279 --> 00:13:16.039
<v Speaker 2>are the actual value supplied when the function is called.

279
00:13:17.120 --> 00:13:20.279
<v Speaker 2>The book then gets into some powerful argument handling features

280
00:13:21.320 --> 00:13:22.919
<v Speaker 2>ARGs and quarks.

281
00:13:23.120 --> 00:13:25.279
<v Speaker 1>Right for when you don't know how many arguments will be.

282
00:13:25.279 --> 00:13:30.360
<v Speaker 2>Passed Exactlygs inside the function definition collects any extra positional

283
00:13:30.480 --> 00:13:34.159
<v Speaker 2>arguments one's passed just by position into a a tupo okay,

284
00:13:34.360 --> 00:13:37.320
<v Speaker 2>and quary's collects any extra keyword arguments one's past is

285
00:13:37.399 --> 00:13:40.519
<v Speaker 2>name value into a dictionary. You can use them together.

286
00:13:41.080 --> 00:13:44.080
<v Speaker 2>The book highlights this as really useful for library authors

287
00:13:44.120 --> 00:13:46.279
<v Speaker 2>who want to offer flexibility to their users.

288
00:13:46.399 --> 00:13:48.000
<v Speaker 1>And Lambda functions.

289
00:13:47.759 --> 00:13:51.679
<v Speaker 2>Lambdas are for creating small, anonymous functions in line. If

290
00:13:51.679 --> 00:13:53.919
<v Speaker 2>you need a simple function just for one quick use,

291
00:13:54.200 --> 00:13:56.799
<v Speaker 2>maybe as an argument to another function, lambda lets you

292
00:13:56.799 --> 00:13:58.960
<v Speaker 2>define it right there without a full deaf statement.

293
00:13:59.279 --> 00:14:01.960
<v Speaker 1>The book suggest us using the number guessing game as

294
00:14:01.960 --> 00:14:04.440
<v Speaker 1>an exercise for function refactoring.

295
00:14:04.679 --> 00:14:07.159
<v Speaker 2>Yeah, taking a simple script and breaking its logic down

296
00:14:07.200 --> 00:14:09.600
<v Speaker 2>into well defined functions is a great way to practice this.

297
00:14:09.679 --> 00:14:13.600
<v Speaker 1>Structuring functions also introduce the idea of variable scope, where

298
00:14:13.639 --> 00:14:14.639
<v Speaker 1>a variable.

299
00:14:14.240 --> 00:14:18.480
<v Speaker 2>Lives crucial concept. Variables defined right at the top level

300
00:14:18.480 --> 00:14:22.799
<v Speaker 2>of a script outside any function have global scope. They

301
00:14:22.840 --> 00:14:25.840
<v Speaker 2>can in principle be accessed from anywhere.

302
00:14:25.960 --> 00:14:28.000
<v Speaker 1>The variables inside a function.

303
00:14:28.080 --> 00:14:31.399
<v Speaker 2>They have local scope. They only exist and are accessible

304
00:14:31.519 --> 00:14:34.679
<v Speaker 2>within that function. If you have a local variable with

305
00:14:34.720 --> 00:14:37.480
<v Speaker 2>the same name as a global variable, the local one

306
00:14:37.519 --> 00:14:40.559
<v Speaker 2>takes precedence inside the function. They are distinct.

307
00:14:40.879 --> 00:14:43.039
<v Speaker 1>What if you need to change a global variable from

308
00:14:43.120 --> 00:14:44.200
<v Speaker 1>inside a function.

309
00:14:44.240 --> 00:14:46.960
<v Speaker 2>You have to explicitly tell Python that's your intention using

310
00:14:47.000 --> 00:14:50.240
<v Speaker 2>the global keyword global, we will bovar at the start

311
00:14:50.279 --> 00:14:52.279
<v Speaker 2>of the function says when I use my global of

312
00:14:52.399 --> 00:14:54.080
<v Speaker 2>ar here, I mean the global one, not a new

313
00:14:54.120 --> 00:14:54.600
<v Speaker 2>local one.

314
00:14:54.639 --> 00:14:57.159
<v Speaker 1>Okay, and non local. That's where nested functions.

315
00:14:57.440 --> 00:15:00.399
<v Speaker 2>Right. If you define a function inside another one function,

316
00:15:00.759 --> 00:15:03.399
<v Speaker 2>nesting non local is used in the inner function to

317
00:15:03.480 --> 00:15:07.159
<v Speaker 2>refer to a variable in the directly enclosing function scope,

318
00:15:07.600 --> 00:15:10.320
<v Speaker 2>but not the global scope. The example in the book

319
00:15:10.360 --> 00:15:13.200
<v Speaker 2>shows an interfunction modifying a variable belonging to the outer

320
00:15:13.279 --> 00:15:14.600
<v Speaker 2>function using non local.

321
00:15:14.759 --> 00:15:20.159
<v Speaker 1>That clarifies the difference. Now a potentially tricky concept recursion.

322
00:15:19.960 --> 00:15:23.679
<v Speaker 2>Ah recursion a function calling itself. It's a way to

323
00:15:23.720 --> 00:15:27.480
<v Speaker 2>solve problems by breaking them down into smaller, self similar

324
00:15:27.519 --> 00:15:28.279
<v Speaker 2>sub problems.

325
00:15:28.320 --> 00:15:30.440
<v Speaker 1>The key is having an escape patch right. A base

326
00:15:30.480 --> 00:15:31.759
<v Speaker 1>case absolutely essential.

327
00:15:31.960 --> 00:15:35.519
<v Speaker 2>The base case or termination condition is the simplest version

328
00:15:35.559 --> 00:15:38.159
<v Speaker 2>of the problem that the function can solve directly without

329
00:15:38.159 --> 00:15:41.840
<v Speaker 2>calling itself again. This stops the chain of calls. Without it,

330
00:15:41.879 --> 00:15:44.480
<v Speaker 2>you get infinite recursion and eventually a recursion er.

331
00:15:44.679 --> 00:15:46.759
<v Speaker 1>Factorial is the textbook example.

332
00:15:46.840 --> 00:15:51.559
<v Speaker 2>It is factorial n is n factorial n one until

333
00:15:51.600 --> 00:15:53.720
<v Speaker 2>you hit the base case factorial one, which is just

334
00:15:53.799 --> 00:15:56.120
<v Speaker 2>one the book traces how the calls stack up and

335
00:15:56.159 --> 00:15:58.360
<v Speaker 2>then unwind to produce the final result.

336
00:15:58.480 --> 00:16:01.519
<v Speaker 1>How does it stack up against just using a loop iteration?

337
00:16:01.799 --> 00:16:04.840
<v Speaker 2>Recursion can often lead to a very elegant, concise code

338
00:16:04.879 --> 00:16:08.960
<v Speaker 2>that mirrors the mathematical definition of a problem. However, iteration

339
00:16:09.320 --> 00:16:12.120
<v Speaker 2>using loops is generally more efficient in terms of speed

340
00:16:12.159 --> 00:16:15.720
<v Speaker 2>and memory usage in Python and many other languages. The

341
00:16:15.759 --> 00:16:18.720
<v Speaker 2>book does mention that some languages, particularly functional ones, can

342
00:16:18.759 --> 00:16:22.120
<v Speaker 2>optimize tail recursion into iteration, removing the overhead.

343
00:16:22.279 --> 00:16:25.639
<v Speaker 1>Speaking of functional, let's shift to that programming style. How

344
00:16:25.639 --> 00:16:28.840
<v Speaker 1>does the book contrast it with procedural.

345
00:16:28.759 --> 00:16:31.559
<v Speaker 2>It's presented as a different mindset. The core idea in

346
00:16:31.559 --> 00:16:35.360
<v Speaker 2>functional programming is to think about computation more like evaluating

347
00:16:35.360 --> 00:16:39.360
<v Speaker 2>mathematical functions. A key principle is avoiding side effects.

348
00:16:39.480 --> 00:16:41.679
<v Speaker 1>Side effects meaning changes to.

349
00:16:41.639 --> 00:16:45.799
<v Speaker 2>State outside the function itself. A pure functions output depends

350
00:16:45.840 --> 00:16:49.039
<v Speaker 2>only on its input arguments and it doesn't modify anything

351
00:16:49.080 --> 00:16:52.799
<v Speaker 2>external like a global variable or a file. This makes

352
00:16:52.879 --> 00:16:55.879
<v Speaker 2>code easier to reason about and test because you know

353
00:16:56.000 --> 00:16:59.240
<v Speaker 2>exactly what it does based on its inputs alone. This

354
00:16:59.279 --> 00:17:01.840
<v Speaker 2>relates to ref prential transparency.

355
00:17:01.200 --> 00:17:03.279
<v Speaker 1>Which means you can replace the function call with its

356
00:17:03.320 --> 00:17:04.519
<v Speaker 1>result pretty much.

357
00:17:04.880 --> 00:17:07.279
<v Speaker 2>If a function is pure, substituting its call with its

358
00:17:07.319 --> 00:17:11.000
<v Speaker 2>return value for the same inputs won't change the program's

359
00:17:11.039 --> 00:17:14.319
<v Speaker 2>overall behavior. Big win for predictability.

360
00:17:13.759 --> 00:17:15.440
<v Speaker 1>And immutable data is encouraged.

361
00:17:15.799 --> 00:17:20.359
<v Speaker 2>Yes, using data structures that cannot be changed after creation.

362
00:17:20.960 --> 00:17:23.559
<v Speaker 2>Python strings are a good example. When you seem to

363
00:17:23.559 --> 00:17:26.799
<v Speaker 2>modify a string, you're actually creating a new string object.

364
00:17:27.759 --> 00:17:31.839
<v Speaker 2>Working with immutable data helps prevent accidental side effects. Because

365
00:17:31.880 --> 00:17:34.759
<v Speaker 2>functions can't secretly change data that other parts of the

366
00:17:34.759 --> 00:17:37.519
<v Speaker 2>program rely on, they return new data.

367
00:17:37.279 --> 00:17:39.960
<v Speaker 1>Instead, and recursion fits naturally here.

368
00:17:40.079 --> 00:17:44.000
<v Speaker 2>Functional programming often emphasizes recursion as a primary control structure,

369
00:17:44.240 --> 00:17:47.079
<v Speaker 2>fitting the mathematical function model well, though as we said,

370
00:17:47.119 --> 00:17:50.279
<v Speaker 2>iteration is still possible and often more performant in practice

371
00:17:50.319 --> 00:17:50.799
<v Speaker 2>in Python.

372
00:17:51.119 --> 00:17:54.240
<v Speaker 1>What advantages does this style offer, according to.

373
00:17:54.240 --> 00:17:57.000
<v Speaker 2>The book, potential for less code, code that's easier to

374
00:17:57.079 --> 00:18:01.599
<v Speaker 2>understand and test due to purity, easier parallelization since pure

375
00:18:01.599 --> 00:18:04.880
<v Speaker 2>functions don't interfere with each other, and sometimes very elegant

376
00:18:05.000 --> 00:18:06.039
<v Speaker 2>retursive solutions.

377
00:18:06.079 --> 00:18:07.759
<v Speaker 1>Any downsides mentioned.

378
00:18:07.480 --> 00:18:11.920
<v Speaker 2>Things like handling continuous input output or interactive systems can

379
00:18:11.960 --> 00:18:16.400
<v Speaker 2>feel less natural with a purely functional approach. Historically, there

380
00:18:16.440 --> 00:18:20.000
<v Speaker 2>were performance concerns, though that's less true now, and the

381
00:18:20.039 --> 00:18:23.480
<v Speaker 2>style the idioms might feel less intuitive at first if

382
00:18:23.480 --> 00:18:27.279
<v Speaker 2>you're used to procedural or ooprogramming, sometimes perceived as a

383
00:18:27.359 --> 00:18:30.960
<v Speaker 2>bit academic, though functional features are increasingly mainstream.

384
00:18:31.319 --> 00:18:34.440
<v Speaker 1>Got it. This leads into higher order functions. What makes

385
00:18:34.440 --> 00:18:36.240
<v Speaker 1>a function higher order.

386
00:18:36.319 --> 00:18:38.519
<v Speaker 2>It comes from the fact that functions in Python are

387
00:18:38.559 --> 00:18:42.079
<v Speaker 2>first class objects. You can assign them to variables, store

388
00:18:42.119 --> 00:18:45.480
<v Speaker 2>them in data structures, pass them as arguments to other functions,

389
00:18:45.640 --> 00:18:47.640
<v Speaker 2>and return them from functions, just.

390
00:18:47.640 --> 00:18:50.039
<v Speaker 1>Like any other data type like a number or a string.

391
00:18:50.240 --> 00:18:53.160
<v Speaker 2>Exactly. A higher order function is simply a function that

392
00:18:53.240 --> 00:18:57.039
<v Speaker 2>either takes one or more functions as arguments or returns

393
00:18:57.039 --> 00:18:59.160
<v Speaker 2>a function as its result, or both.

394
00:18:59.319 --> 00:19:01.799
<v Speaker 1>Key consop functional programming, very much so.

395
00:19:02.119 --> 00:19:05.200
<v Speaker 2>The book shows examples like passing a calculation function into

396
00:19:05.240 --> 00:19:08.720
<v Speaker 2>another function to tax salary tax funk, or a function

397
00:19:08.759 --> 00:19:11.240
<v Speaker 2>that takes an action function applied data.

398
00:19:11.039 --> 00:19:15.079
<v Speaker 1>Action funk, and functions returning functions that leads to closures.

399
00:19:15.720 --> 00:19:19.200
<v Speaker 2>Yes, when a function defined inside another function an inner

400
00:19:19.240 --> 00:19:22.319
<v Speaker 2>function is returned, it carries with it the environment of

401
00:19:22.400 --> 00:19:26.000
<v Speaker 2>the scope in which it was created. It closes over

402
00:19:26.359 --> 00:19:28.079
<v Speaker 2>any variables that references from.

403
00:19:27.920 --> 00:19:31.279
<v Speaker 1>That outer scope, so it remembers variables from the outer

404
00:19:31.400 --> 00:19:33.880
<v Speaker 1>function even after the outer function has finished.

405
00:19:34.039 --> 00:19:36.799
<v Speaker 2>Precisely, the reset function example in the book with the

406
00:19:36.799 --> 00:19:40.400
<v Speaker 2>inner lambda shows that the return lambda still has access

407
00:19:40.400 --> 00:19:42.440
<v Speaker 2>to the addition variable from reset functions.

408
00:19:42.480 --> 00:19:45.559
<v Speaker 1>Scope and currying related but different.

409
00:19:45.680 --> 00:19:49.319
<v Speaker 2>Related. Currying, named after Haskell curry is a technique where

410
00:19:49.359 --> 00:19:52.359
<v Speaker 2>you take a function that accepts multiple arguments and transform

411
00:19:52.359 --> 00:19:54.440
<v Speaker 2>it into a sequence of functions that each take a

412
00:19:54.480 --> 00:19:58.279
<v Speaker 2>single argument. More practically, in Python, it often means creating

413
00:19:58.319 --> 00:20:01.759
<v Speaker 2>a new function by pre filling or binding some of

414
00:20:01.759 --> 00:20:03.720
<v Speaker 2>the arguments of an existing function.

415
00:20:03.599 --> 00:20:06.920
<v Speaker 1>Like taking multiply ab and creating double multiply.

416
00:20:06.680 --> 00:20:09.920
<v Speaker 2>Two B's essentially yes, yeah, you create a specialized version

417
00:20:09.920 --> 00:20:13.400
<v Speaker 2>by fixing one or more parameters. It's about creating reusable

418
00:20:13.519 --> 00:20:14.559
<v Speaker 2>function variations.

419
00:20:14.839 --> 00:20:18.599
<v Speaker 1>Okay, let's switch gears completely to the other major paradigm,

420
00:20:18.880 --> 00:20:21.640
<v Speaker 1>object oriented programming OP.

421
00:20:21.519 --> 00:20:24.160
<v Speaker 2>Right, a very different way to structure things. The core

422
00:20:24.279 --> 00:20:28.079
<v Speaker 2>idea here is to bundle data called attributes or properties,

423
00:20:28.519 --> 00:20:31.440
<v Speaker 2>and the operations that work on that data called methods,

424
00:20:31.960 --> 00:20:34.319
<v Speaker 2>together into units called classes.

425
00:20:34.400 --> 00:20:38.000
<v Speaker 1>And you work with instances of these classes exactly.

426
00:20:38.079 --> 00:20:40.400
<v Speaker 2>You create objects, which are instances of a class. So

427
00:20:40.440 --> 00:20:42.640
<v Speaker 2>you might have an employee class, and then John and

428
00:20:42.720 --> 00:20:46.319
<v Speaker 2>Jane could be specific employee objects, each with their own name, ID,

429
00:20:46.519 --> 00:20:50.000
<v Speaker 2>et cetera, but sharing the methods defined in the employee class,

430
00:20:50.240 --> 00:20:51.279
<v Speaker 2>like calculate pay.

431
00:20:51.559 --> 00:20:54.680
<v Speaker 1>So design involves identifying these objects.

432
00:20:54.799 --> 00:20:57.200
<v Speaker 2>Yeah, you look at the problem domain and identify the

433
00:20:57.279 --> 00:20:59.720
<v Speaker 2>key entities. What data do they need to store? Their

434
00:20:59.759 --> 00:21:02.680
<v Speaker 2>still eight, what actions can they perform or have performed

435
00:21:02.720 --> 00:21:06.200
<v Speaker 2>on them? Their methods or interface objects then interact by

436
00:21:06.200 --> 00:21:09.480
<v Speaker 2>calling methods on each other sending messages. The pump system

437
00:21:09.519 --> 00:21:12.920
<v Speaker 2>example illustrates how this can create modular systems where obvious

438
00:21:13.039 --> 00:21:15.079
<v Speaker 2>only need to know about their direct collaborators.

439
00:21:15.200 --> 00:21:18.160
<v Speaker 1>Defining a class uses the class keyword in Python.

440
00:21:17.960 --> 00:21:22.599
<v Speaker 2>Simple as class name. Then inside you define attributes and methods.

441
00:21:22.279 --> 00:21:24.839
<v Speaker 1>And creating an object an instance, you call.

442
00:21:24.720 --> 00:21:27.039
<v Speaker 2>The class name as if it were a function. P

443
00:21:27.119 --> 00:21:32.079
<v Speaker 2>one person elis thirty. Now P one is a variable

444
00:21:32.359 --> 00:21:34.680
<v Speaker 2>holding a reference to a person object in memory.

445
00:21:34.720 --> 00:21:36.480
<v Speaker 1>What if I do P two equals P one? Does

446
00:21:36.519 --> 00:21:37.359
<v Speaker 1>that make a copy?

447
00:21:37.559 --> 00:21:40.160
<v Speaker 2>No, that's a crucial point the book makes. It copies

448
00:21:40.200 --> 00:21:43.119
<v Speaker 2>the reference the memory address. P one and P two

449
00:21:43.200 --> 00:21:46.599
<v Speaker 2>now point to the exact same person object. Changing the

450
00:21:46.640 --> 00:21:48.880
<v Speaker 2>object via P one will also be reflected when you

451
00:21:48.920 --> 00:21:51.519
<v Speaker 2>look at it via P two. The ID function can

452
00:21:51.519 --> 00:21:52.839
<v Speaker 2>show they have the same memory id.

453
00:21:53.079 --> 00:21:55.440
<v Speaker 1>If you just print P one you get something cryptic.

454
00:21:55.720 --> 00:21:58.480
<v Speaker 2>Usually yeah. The default is the class name and its

455
00:21:58.519 --> 00:22:01.440
<v Speaker 2>memory address. To get something meaningful, you need to define

456
00:22:01.440 --> 00:22:04.559
<v Speaker 2>a special method called stye self within the class. That

457
00:22:04.599 --> 00:22:07.880
<v Speaker 2>method should return the string representation you want print to use.

458
00:22:08.039 --> 00:22:10.359
<v Speaker 1>Python handles cleaning up these objects automatically.

459
00:22:10.640 --> 00:22:14.359
<v Speaker 2>Yes, that's garbage collection, a huge advantage over language is

460
00:22:14.440 --> 00:22:17.279
<v Speaker 2>like C plus plus where you have to manage memory manually.

461
00:22:18.319 --> 00:22:21.319
<v Speaker 2>Python keeps track of references, and when an object has

462
00:22:21.359 --> 00:22:24.480
<v Speaker 2>no more references pointing to it, it gets automatically cleaned up.

463
00:22:24.519 --> 00:22:28.000
<v Speaker 2>Freeing the memory lets you focus on logic, not memory leaks.

464
00:22:28.200 --> 00:22:31.920
<v Speaker 1>Can attributes belong to the class itself, not just individual objects.

465
00:22:32.200 --> 00:22:35.200
<v Speaker 2>They can. Class attributes are shared by all instances of

466
00:22:35.240 --> 00:22:38.839
<v Speaker 2>the class. Useful for constants related to the class, or

467
00:22:38.880 --> 00:22:41.880
<v Speaker 2>maybe tracking things like how many instances have been created.

468
00:22:42.160 --> 00:22:46.559
<v Speaker 2>Account dot instance count Instance attributes are specific to each object.

469
00:22:47.079 --> 00:22:48.640
<v Speaker 2>My account dot balance.

470
00:22:48.440 --> 00:22:51.759
<v Speaker 1>And those special methods like in it and stray have

471
00:22:51.880 --> 00:22:52.920
<v Speaker 1>double underscores.

472
00:22:53.079 --> 00:22:55.960
<v Speaker 2>Right, and it's a constructor called automatically when you create

473
00:22:55.960 --> 00:22:59.039
<v Speaker 2>an object stave sopra r for printing. There are many

474
00:22:59.039 --> 00:23:02.240
<v Speaker 2>others so cautions. You generally shouldn't name your own methods

475
00:23:02.279 --> 00:23:05.160
<v Speaker 2>like something unless you're intentionally overriding one of Python's built

476
00:23:05.160 --> 00:23:05.839
<v Speaker 2>in behaviors.

477
00:23:06.000 --> 00:23:07.920
<v Speaker 1>Are there methods that work on the class directly.

478
00:23:08.279 --> 00:23:12.000
<v Speaker 2>Yes. Class methods often decorated with at class method and

479
00:23:12.079 --> 00:23:14.920
<v Speaker 2>static methods at static method. They can be called on

480
00:23:15.000 --> 00:23:18.519
<v Speaker 2>the class itself, my class dot class method rather than

481
00:23:18.519 --> 00:23:22.640
<v Speaker 2>an instance. Useful for factory methods. Alternative ways to create

482
00:23:22.680 --> 00:23:25.759
<v Speaker 2>instances or utility functions related to the class.

483
00:23:25.920 --> 00:23:29.440
<v Speaker 1>How do classes connect? Inheritance seems key in OOP.

484
00:23:29.920 --> 00:23:33.799
<v Speaker 2>Inheritance is a cornerstone. It lets you create a new class, subclass,

485
00:23:33.839 --> 00:23:38.039
<v Speaker 2>or child class that inherits properties, attributes, and methods from

486
00:23:38.079 --> 00:23:42.119
<v Speaker 2>an existing class, superclass, or parent class. It promotes code

487
00:23:42.119 --> 00:23:45.440
<v Speaker 2>reuse and establishes is a relationships.

488
00:23:45.000 --> 00:23:47.759
<v Speaker 1>Like a manager is an employee, which is a person.

489
00:23:47.920 --> 00:23:51.480
<v Speaker 2>Perfect example, the manager inherits from employee, gaining its attributes

490
00:23:51.519 --> 00:23:55.160
<v Speaker 2>and methods, and employee inherits from person. The subclass can

491
00:23:55.240 --> 00:23:58.279
<v Speaker 2>use the inherited features directly, it can override them, provide

492
00:23:58.319 --> 00:24:00.920
<v Speaker 2>its own version, and it can add completely new features

493
00:24:00.960 --> 00:24:01.440
<v Speaker 2>of its own.

494
00:24:01.559 --> 00:24:04.039
<v Speaker 1>If a child class needs its own in it, how

495
00:24:04.039 --> 00:24:06.160
<v Speaker 1>does it make sure the parents in it also runs.

496
00:24:06.599 --> 00:24:10.200
<v Speaker 2>The standard way is to call super dot end inside

497
00:24:10.240 --> 00:24:13.640
<v Speaker 2>the child's in it. Super gives you a reference to

498
00:24:13.680 --> 00:24:16.960
<v Speaker 2>the parent class, allowing you to call its methods, including

499
00:24:17.000 --> 00:24:20.359
<v Speaker 2>the constructor. To ensure proper initialization.

500
00:24:19.920 --> 00:24:22.480
<v Speaker 1>And overwriting a method is just redefining it in the

501
00:24:22.559 --> 00:24:23.160
<v Speaker 1>child Yes.

502
00:24:23.559 --> 00:24:26.160
<v Speaker 2>If person has a display method and employee needs a

503
00:24:26.160 --> 00:24:29.960
<v Speaker 2>different display, you just define display again an employee. If

504
00:24:30.000 --> 00:24:32.640
<v Speaker 2>you still need the parents behavior inside the overridden method,

505
00:24:32.720 --> 00:24:34.559
<v Speaker 2>you can call it using super dot display.

506
00:24:34.799 --> 00:24:37.720
<v Speaker 1>The book offers advice on when inheritance is appropriate.

507
00:24:37.839 --> 00:24:40.599
<v Speaker 2>Yeah. It suggests asking does the child really use or

508
00:24:40.680 --> 00:24:44.279
<v Speaker 2>specialize the parent's features? Does the parent's core functionality make

509
00:24:44.319 --> 00:24:47.319
<v Speaker 2>sense in the child's context. The dinghy is a conveyance

510
00:24:47.359 --> 00:24:50.960
<v Speaker 2>example highlights thinking about whether the relationship truly fits the

511
00:24:51.119 --> 00:24:52.680
<v Speaker 2>is model meaningfully.

512
00:24:53.000 --> 00:24:57.680
<v Speaker 1>Python supports inheriting from multiple parents. Multiple inheritance it does.

513
00:24:57.759 --> 00:25:03.359
<v Speaker 2>You can list multiple parent classes slay my class PARENTA

514
00:25:03.640 --> 00:25:07.240
<v Speaker 2>parent B. This can be powerful, but also adds complexity,

515
00:25:07.319 --> 00:25:11.279
<v Speaker 2>particularly regarding which parent's method gets called if both define

516
00:25:11.279 --> 00:25:14.359
<v Speaker 2>a method with the same name. Python has a defined

517
00:25:14.400 --> 00:25:17.880
<v Speaker 2>method resolution order MRO to handle this, but it's something

518
00:25:17.920 --> 00:25:21.119
<v Speaker 2>to be aware of the order you list the parents matters, okay.

519
00:25:21.119 --> 00:25:24.240
<v Speaker 1>Making our custom objects work with standard operators like plus

520
00:25:24.279 --> 00:25:27.000
<v Speaker 1>a that's operator overloading exactly.

521
00:25:27.079 --> 00:25:29.680
<v Speaker 2>It allows you to define how standard operators should behave

522
00:25:29.759 --> 00:25:32.839
<v Speaker 2>when applied to instances of your custom classes. The goal

523
00:25:32.920 --> 00:25:36.039
<v Speaker 2>is to make code using your objects more intuitive and readable.

524
00:25:35.839 --> 00:25:38.880
<v Speaker 1>Like vector one plus vector two instead of vector one dot.

525
00:25:38.680 --> 00:25:41.960
<v Speaker 2>Ad vector Decisely, you achieve this by implementing more of

526
00:25:41.960 --> 00:25:46.440
<v Speaker 2>those special double underscore methods add for plus subframeke mole

527
00:25:46.559 --> 00:25:48.880
<v Speaker 2>for a cup, a q for ltf for eight, and

528
00:25:48.920 --> 00:25:49.519
<v Speaker 2>many others.

529
00:25:49.640 --> 00:25:52.319
<v Speaker 1>And inside adds self other self is the left side,

530
00:25:52.359 --> 00:25:53.319
<v Speaker 1>other is the right.

531
00:25:53.319 --> 00:25:55.680
<v Speaker 2>Correct Inside that method you define what it means to

532
00:25:55.720 --> 00:25:58.359
<v Speaker 2>add other to self. The book shows you can use

533
00:25:58.480 --> 00:26:01.119
<v Speaker 2>is instance other to check the type of other and

534
00:26:01.160 --> 00:26:04.640
<v Speaker 2>potentially handle addition with different types, like adding an integer

535
00:26:04.680 --> 00:26:05.680
<v Speaker 2>to your custom object.

536
00:26:06.119 --> 00:26:09.680
<v Speaker 1>What about properties and decorators like AT property.

537
00:26:09.400 --> 00:26:13.359
<v Speaker 2>Decorators using the AT syntax are a way to modify

538
00:26:13.559 --> 00:26:17.880
<v Speaker 2>or enhance functions or methods in Python. AT property is

539
00:26:17.920 --> 00:26:20.359
<v Speaker 2>a specific built in decorator that lets you define a

540
00:26:20.400 --> 00:26:23.759
<v Speaker 2>method but access it as if it were a simple attribute, So.

541
00:26:23.720 --> 00:26:26.880
<v Speaker 1>My object dot value might actually call a method behind

542
00:26:26.880 --> 00:26:27.720
<v Speaker 1>the scenes exactly.

543
00:26:27.799 --> 00:26:30.000
<v Speaker 2>It's often used to create getters. You can put logic

544
00:26:30.079 --> 00:26:32.440
<v Speaker 2>inside the method, maybe calculate the value on the fly,

545
00:26:33.160 --> 00:26:36.799
<v Speaker 2>or check permissions whenever someone accesses my object dot value.

546
00:26:36.640 --> 00:26:39.559
<v Speaker 1>Can you control assignment too, Like my object dot value

547
00:26:39.559 --> 00:26:40.200
<v Speaker 1>equals ten.

548
00:26:40.440 --> 00:26:43.519
<v Speaker 2>Yes. Using me at property name dot setter decorator, you

549
00:26:43.599 --> 00:26:47.599
<v Speaker 2>define another method decorated with at value dot setter properties value,

550
00:26:47.759 --> 00:26:49.799
<v Speaker 2>and that method will be called whenever someone tries to

551
00:26:49.799 --> 00:26:52.880
<v Speaker 2>assign to my object dot value. Great for validation or

552
00:26:52.880 --> 00:26:53.920
<v Speaker 2>triggering actions on.

553
00:26:53.960 --> 00:26:56.160
<v Speaker 1>Change and at delet for delay.

554
00:26:56.440 --> 00:27:00.039
<v Speaker 2>Right at value dot deleter defines the method called the

555
00:27:00.119 --> 00:27:03.640
<v Speaker 2>end of myobject dot value is executed. The book often

556
00:27:03.720 --> 00:27:07.079
<v Speaker 2>shows these us with a private backing attribute like value,

557
00:27:07.119 --> 00:27:10.680
<v Speaker 2>with a single underscore to store the actual data, enforcing

558
00:27:10.720 --> 00:27:12.880
<v Speaker 2>access through the property methods for encapsulation.

559
00:27:13.279 --> 00:27:18.240
<v Speaker 1>Moving into more advanced concepts, protocols, polymorphism descriptors. What's the

560
00:27:18.279 --> 00:27:19.799
<v Speaker 1>idea of a protocol? In Python?

561
00:27:20.000 --> 00:27:23.559
<v Speaker 2>A protocol is like an informal interface. It's not something

562
00:27:23.640 --> 00:27:27.319
<v Speaker 2>you formally declare. It's defined by the expected methods in behavior.

563
00:27:27.960 --> 00:27:30.759
<v Speaker 2>If an object has the necessary methods like itter and

564
00:27:31.039 --> 00:27:34.400
<v Speaker 2>next for the iteration protocol, it's considered to adhere to

565
00:27:34.440 --> 00:27:37.640
<v Speaker 2>that protocol, regardless of his actual class or inheritance.

566
00:27:37.720 --> 00:27:39.000
<v Speaker 1>This sounds like duck typing.

567
00:27:39.400 --> 00:27:41.759
<v Speaker 2>It's the heart of duck typing. If it walks like

568
00:27:41.759 --> 00:27:43.480
<v Speaker 2>a duck and quacks like a duck, then it must

569
00:27:43.519 --> 00:27:46.400
<v Speaker 2>be a duck. Python often cares more about whether an

570
00:27:46.400 --> 00:27:49.079
<v Speaker 2>object can do what's needed, does it have the right methods,

571
00:27:49.559 --> 00:27:51.160
<v Speaker 2>rather than what its specific type is.

572
00:27:51.200 --> 00:27:52.599
<v Speaker 1>And polymorphism flows from this.

573
00:27:53.200 --> 00:27:57.680
<v Speaker 2>Yes, polymorphism means many forms. It's the ability for different

574
00:27:57.720 --> 00:28:01.839
<v Speaker 2>objects potentially of different types, maybe not even related by inheritance,

575
00:28:02.039 --> 00:28:04.720
<v Speaker 2>but adhering to the same protocol to respond to the

576
00:28:04.720 --> 00:28:07.759
<v Speaker 2>same message the same method call in their own specific way.

577
00:28:08.319 --> 00:28:12.599
<v Speaker 2>Len works on strings, lists, dictionaries because they all implement

578
00:28:12.640 --> 00:28:15.279
<v Speaker 2>the len method part of the size protocol, but how

579
00:28:15.279 --> 00:28:16.720
<v Speaker 2>they calculate their length differs.

580
00:28:17.079 --> 00:28:20.799
<v Speaker 1>The context manager protocol enables the with statement exactly.

581
00:28:20.960 --> 00:28:24.200
<v Speaker 2>Any object with enter and exit methods supports the context

582
00:28:24.240 --> 00:28:28.480
<v Speaker 2>manager protocol. The width object is variable. Statement automatically calls

583
00:28:28.480 --> 00:28:31.000
<v Speaker 2>object dot enter the start. It's return value goes into

584
00:28:31.039 --> 00:28:34.119
<v Speaker 2>variable and guarantees object dot exit is called at the end.

585
00:28:34.440 --> 00:28:37.519
<v Speaker 2>Even if errors occur within the width block. Essential for

586
00:28:37.599 --> 00:28:40.079
<v Speaker 2>resource management like files or network connections.

587
00:28:40.279 --> 00:28:42.880
<v Speaker 1>And descriptors. They sound complex, they.

588
00:28:42.799 --> 00:28:46.039
<v Speaker 2>Are a more advanced mechanism. A descriptor is an object

589
00:28:46.079 --> 00:28:49.119
<v Speaker 2>attributed to a class that defines special behavior when that

590
00:28:49.200 --> 00:28:53.119
<v Speaker 2>attribute is accessed on an instance. They control access using

591
00:28:53.200 --> 00:28:55.880
<v Speaker 2>methods like get, set, and delete defined on the descript

592
00:28:56.160 --> 00:29:00.599
<v Speaker 2>object itself. Properties are actually implemented using descriptors. The book

593
00:29:00.680 --> 00:29:04.480
<v Speaker 2>also mentions related attribute access methods. Get it is called

594
00:29:04.559 --> 00:29:06.759
<v Speaker 2>only as a last resort if an attribute isn't found

595
00:29:06.799 --> 00:29:10.200
<v Speaker 2>through normal means. Get attribute is called for every attribute

596
00:29:10.200 --> 00:29:14.599
<v Speaker 2>access use with extreme care to avoid infinite recursion, and

597
00:29:14.720 --> 00:29:16.880
<v Speaker 2>set attry is called for every attribute assignment.

598
00:29:16.920 --> 00:29:22.000
<v Speaker 1>Okay, let's dive deep into iteration, iterables, iterators, generators, quarantines.

599
00:29:22.160 --> 00:29:24.799
<v Speaker 2>What's the difference, okay and itterable is anything you could

600
00:29:24.839 --> 00:29:28.240
<v Speaker 2>loop over with a for loop. Think lists, strains, dictionaries.

601
00:29:28.400 --> 00:29:30.920
<v Speaker 2>The key requirement is that it must have an itter method.

602
00:29:30.960 --> 00:29:33.359
<v Speaker 2>An gives you an iterator. The iterator is the object

603
00:29:33.400 --> 00:29:35.960
<v Speaker 2>that actually keeps track of the position and produces the

604
00:29:36.000 --> 00:29:39.240
<v Speaker 2>next value. It must have a next method that returns

605
00:29:39.279 --> 00:29:42.039
<v Speaker 2>the next item and raises a stop iteration exception. When

606
00:29:42.039 --> 00:29:44.759
<v Speaker 2>there are no more items. Iterators usually also have an

607
00:29:44.799 --> 00:29:46.319
<v Speaker 2>inter method that just returns self.

608
00:29:46.559 --> 00:29:49.359
<v Speaker 1>So four loops work by getting an iterator from the

609
00:29:49.400 --> 00:29:53.039
<v Speaker 1>iterable then calling next on it repeatedly exactly.

610
00:29:53.440 --> 00:29:56.119
<v Speaker 2>The inner tool's module in Python provides lots of pre

611
00:29:56.160 --> 00:29:57.519
<v Speaker 2>built efficient iterators.

612
00:29:57.799 --> 00:30:00.799
<v Speaker 1>Where do generators fit int.

613
00:30:00.200 --> 00:30:03.519
<v Speaker 2>Are a super convenient way to create iterators. Instead of

614
00:30:03.519 --> 00:30:06.880
<v Speaker 2>writing a full class with iter and next, you write

615
00:30:06.880 --> 00:30:08.079
<v Speaker 2>a function that uses.

616
00:30:07.880 --> 00:30:10.039
<v Speaker 1>The yield keyword yield instead of return.

617
00:30:10.279 --> 00:30:13.079
<v Speaker 2>Right when you call a generator function, it doesn't run immediately.

618
00:30:13.079 --> 00:30:15.960
<v Speaker 2>It returns a special generator object, which is an iterator.

619
00:30:16.680 --> 00:30:19.599
<v Speaker 2>Each time you call next on the generator object or

620
00:30:19.680 --> 00:30:22.400
<v Speaker 2>use it in a for loop, the function's code runs

621
00:30:22.559 --> 00:30:25.480
<v Speaker 2>until it hits a yield statement. It sends the yielded

622
00:30:25.559 --> 00:30:29.720
<v Speaker 2>value back, and then pauses its execution right there, preserving its.

623
00:30:29.599 --> 00:30:32.079
<v Speaker 1>Local state lazy evaluation exactly.

624
00:30:32.279 --> 00:30:35.000
<v Speaker 2>It only generates the next value when asked. This is

625
00:30:35.039 --> 00:30:38.519
<v Speaker 2>incredibly memory efficient for large sequences or even infinite ones,

626
00:30:38.599 --> 00:30:41.279
<v Speaker 2>because you don't store everything in memory at once. The

627
00:30:41.359 --> 00:30:44.000
<v Speaker 2>even subto example in the book likely demonstrates this.

628
00:30:44.599 --> 00:30:48.920
<v Speaker 1>Okay, so generators yield values out. How are courotines different.

629
00:30:48.920 --> 00:30:52.440
<v Speaker 2>Core routines are like advanced generators. They can also yield

630
00:30:52.440 --> 00:30:54.839
<v Speaker 2>a pause, but the key difference is they can also

631
00:30:54.880 --> 00:30:59.079
<v Speaker 2>receive value sent into them. Well paused yield can act

632
00:30:59.119 --> 00:31:01.920
<v Speaker 2>as an expression that sieves of value passed via the

633
00:31:02.000 --> 00:31:05.519
<v Speaker 2>send method, so they become little processing units you can

634
00:31:05.559 --> 00:31:09.319
<v Speaker 2>push data into. They often need to be primed first,

635
00:31:09.799 --> 00:31:12.160
<v Speaker 2>calling next or send none to run up to the

636
00:31:12.160 --> 00:31:15.400
<v Speaker 2>first yield before you can send data. The book mentions

637
00:31:15.400 --> 00:31:18.440
<v Speaker 2>a rep example suggesting a coroutine that receives lines of

638
00:31:18.480 --> 00:31:21.519
<v Speaker 2>text and processes them. They also have ways to handle being.

639
00:31:21.359 --> 00:31:25.359
<v Speaker 1>Closed fascinating distinction. Let's quickly run through Python's main built

640
00:31:25.400 --> 00:31:26.440
<v Speaker 1>in collections sure.

641
00:31:26.480 --> 00:31:30.319
<v Speaker 2>The four work horses mentioned are lists, tuples, sets.

642
00:31:30.000 --> 00:31:32.960
<v Speaker 1>And dictionaries check mutable, sequence.

643
00:31:32.799 --> 00:31:36.119
<v Speaker 2>Ordered, unchangeable, allow duplicates, parentheses.

644
00:31:35.559 --> 00:31:37.240
<v Speaker 1>Check immutable sequence.

645
00:31:36.960 --> 00:31:40.920
<v Speaker 2>Ordered unchangeable, n duplicates, curly braces.

646
00:31:40.519 --> 00:31:45.559
<v Speaker 1>Test stuck mutable collection of unique items great for membership testing, dictionaries,

647
00:31:45.880 --> 00:31:50.200
<v Speaker 1>unordered mostly ordered since three point seven, key value pairs,

648
00:31:50.720 --> 00:31:53.920
<v Speaker 1>n duplicate keys, curly braces que check.

649
00:31:54.240 --> 00:31:58.079
<v Speaker 2>Key based lookup mapping keys to values conceptually based on

650
00:31:58.119 --> 00:32:01.000
<v Speaker 2>hash tables for efficiency. The book also points to the

651
00:32:01.000 --> 00:32:05.119
<v Speaker 2>collections module for more specialized types. Like counter recounting things,

652
00:32:05.359 --> 00:32:08.200
<v Speaker 2>and order addict if you need guaranteed insertion order.

653
00:32:08.319 --> 00:32:11.720
<v Speaker 1>The guide also touches on abstract data types ADTs like

654
00:32:11.799 --> 00:32:12.759
<v Speaker 1>queues and stacks.

655
00:32:12.880 --> 00:32:16.160
<v Speaker 2>Right ADTs are more about the concept the behavior rather

656
00:32:16.200 --> 00:32:17.559
<v Speaker 2>than a specific implementation.

657
00:32:17.799 --> 00:32:21.240
<v Speaker 1>Que first in, first out FIFO like a line.

658
00:32:20.960 --> 00:32:24.400
<v Speaker 2>YEP, add to the back, remove from the front, order preserved.

659
00:32:24.119 --> 00:32:28.359
<v Speaker 1>Stack last in first out LIFO like plates add to the.

660
00:32:28.279 --> 00:32:31.160
<v Speaker 2>Top, removed from the top, order also preserved. The book

661
00:32:31.160 --> 00:32:33.680
<v Speaker 2>shows how you can use Python lists to mimic thesele's

662
00:32:33.680 --> 00:32:35.839
<v Speaker 2>a penpop for a stack, a pen pop a queue,

663
00:32:36.039 --> 00:32:39.359
<v Speaker 2>but notes pop is inefficient for lists. It then provides

664
00:32:39.400 --> 00:32:42.039
<v Speaker 2>proper Q and stack class examples using an internal list

665
00:32:42.160 --> 00:32:45.440
<v Speaker 2>but exposing the correct ADT methods on key toq or push.

666
00:32:45.279 --> 00:32:49.079
<v Speaker 1>Pop Circling back to functionalideas, dot map and filter two.

667
00:32:49.119 --> 00:32:53.200
<v Speaker 2>Very useful higher order functions for working with iterables. Filter

668
00:32:53.319 --> 00:32:56.400
<v Speaker 2>function iterable takes a function that returns true or false.

669
00:32:57.160 --> 00:32:59.400
<v Speaker 2>It applies this test to every item in the iterable

670
00:32:59.640 --> 00:33:02.160
<v Speaker 2>and gives you back an iterator containing only the items

671
00:33:02.160 --> 00:33:03.799
<v Speaker 2>for which the function returned true.

672
00:33:03.880 --> 00:33:05.559
<v Speaker 1>Good for selecting data exactly.

673
00:33:05.839 --> 00:33:08.960
<v Speaker 2>And map function iterable one applies a given function to

674
00:33:09.000 --> 00:33:11.720
<v Speaker 2>every item in the iterable or corresponding items if you

675
00:33:11.759 --> 00:33:15.079
<v Speaker 2>pass multiple itterables and returns an iterator of the results.

676
00:33:15.519 --> 00:33:19.319
<v Speaker 2>Good for transforming data precisely applying an operation across a

677
00:33:19.359 --> 00:33:22.920
<v Speaker 2>whole collection. The examples likely show things like squaring every

678
00:33:23.000 --> 00:33:25.599
<v Speaker 2>number in a list or extracting a specific piece of

679
00:33:25.680 --> 00:33:26.960
<v Speaker 2>data from a list of objects.

680
00:33:27.519 --> 00:33:31.079
<v Speaker 1>Powerful tools for data manipulation in a functional style.

681
00:33:31.000 --> 00:33:35.039
<v Speaker 2>Definitely encourages thinking about operations on collections as transformations rather

682
00:33:35.079 --> 00:33:36.480
<v Speaker 2>than modifying things in place.

683
00:33:36.799 --> 00:33:39.759
<v Speaker 1>Lastly, the book mentions a tic tac toe example as

684
00:33:39.799 --> 00:33:41.119
<v Speaker 1>a way to tie things together.

685
00:33:41.519 --> 00:33:44.240
<v Speaker 2>Yeah, it's presented as a mini case study. It likely

686
00:33:44.279 --> 00:33:50.119
<v Speaker 2>shows how concepts like classes board player, game inheritance, human player,

687
00:33:50.519 --> 00:33:54.880
<v Speaker 2>computer player inheriting from player data structures, maybe a list

688
00:33:54.880 --> 00:33:57.519
<v Speaker 2>of lists for the board and methods all combined to

689
00:33:57.519 --> 00:34:01.559
<v Speaker 2>build a recognizable application and administrates putting the pieces into practice.

690
00:34:01.599 --> 00:34:05.319
<v Speaker 1>Wow. Okay, that was quite the journey through this beginner's guide.

691
00:34:05.359 --> 00:34:08.480
<v Speaker 1>We really covered the spectrum. Started with the basics Python's

692
00:34:08.559 --> 00:34:10.159
<v Speaker 1>dynamic nature setting up.

693
00:34:10.079 --> 00:34:15.920
<v Speaker 2>Right, Then the fundamental building blocks data types like strings, number, booleans, none,

694
00:34:16.159 --> 00:34:20.079
<v Speaker 2>control flow using if lf else, and loops like while

695
00:34:20.119 --> 00:34:22.920
<v Speaker 2>and four, and the critical role of indentation.

696
00:34:22.760 --> 00:34:28.679
<v Speaker 1>Instruction code with functions, understanding parameters, arguments, arcs, quarks, scope, rules, global,

697
00:34:28.719 --> 00:34:30.440
<v Speaker 1>non local, and even recursion.

698
00:34:30.599 --> 00:34:33.159
<v Speaker 2>We explored different philosophies to the functional approach, with its

699
00:34:33.280 --> 00:34:38.000
<v Speaker 2>focus on pure functions, immutability, referential transparency, and tools like

700
00:34:38.079 --> 00:34:40.519
<v Speaker 2>higher order functions, closures and currying.

701
00:34:40.440 --> 00:34:45.719
<v Speaker 1>And contrasted that with object orientation classes, objects, attributes, methods,

702
00:34:45.960 --> 00:34:50.320
<v Speaker 1>the power of inheritance, operator overlooting for natural syntax, and

703
00:34:50.480 --> 00:34:52.440
<v Speaker 1>niceties like properties and decorators.

704
00:34:52.480 --> 00:34:55.559
<v Speaker 2>We touched on some deeper Python mechanics too, like protocols

705
00:34:55.639 --> 00:35:00.400
<v Speaker 2>enabling duct typing and polymorphism, context managers for reliable resource

706
00:35:00.440 --> 00:35:04.559
<v Speaker 2>handling with descriptions behind the scenes, and the nuances of attribute.

707
00:35:04.079 --> 00:35:08.960
<v Speaker 1>Access methods, plus advanced iteration patterns iterables giving iterators, the

708
00:35:09.000 --> 00:35:12.719
<v Speaker 1>memory efficiency of generators using yield, and the data receiving

709
00:35:12.760 --> 00:35:14.800
<v Speaker 1>capabilities of corotines, and of.

710
00:35:14.760 --> 00:35:19.079
<v Speaker 2>Course Python's core collections lists, tuples, sets, dictionaries, along with

711
00:35:19.159 --> 00:35:22.880
<v Speaker 2>conceptual ADTs like queues and stacks, and functional hopers like

712
00:35:22.960 --> 00:35:23.599
<v Speaker 2>map and filter.

713
00:35:23.800 --> 00:35:26.519
<v Speaker 1>It feels like this deep dive really extracted the essence

714
00:35:26.559 --> 00:35:29.800
<v Speaker 1>from that guide, laying out a roadmap from basic syntax

715
00:35:29.880 --> 00:35:32.840
<v Speaker 1>to some pretty sophisticated concepts needed to really get good

716
00:35:32.880 --> 00:35:33.440
<v Speaker 1>at Python.

717
00:35:33.599 --> 00:35:35.440
<v Speaker 2>Yeah, it covers a lot of ground necessary to move

718
00:35:35.480 --> 00:35:37.079
<v Speaker 2>from beginner to experience developer.

719
00:35:37.280 --> 00:35:40.440
<v Speaker 1>Reflecting on all of this from the simplest variable assignment

720
00:35:40.559 --> 00:35:44.320
<v Speaker 1>right up to complex things like metaclasses implicitly enabling descriptors,

721
00:35:44.679 --> 00:35:47.719
<v Speaker 1>or choosing between recursion and iteration, or deciding between a

722
00:35:47.760 --> 00:35:52.159
<v Speaker 1>functional or object oriented design. Python gives you so many tools,

723
00:35:52.199 --> 00:35:54.119
<v Speaker 1>so many ways to think. It really makes you wonder,

724
00:35:54.159 --> 00:35:56.760
<v Speaker 1>doesn't it. As you gain experience, how do you actually

725
00:35:56.920 --> 00:35:59.239
<v Speaker 1>choose when faced with a new problem? How do you

726
00:35:59.320 --> 00:36:02.480
<v Speaker 1>navigate this rich landscape and select the most effective, the

727
00:36:02.519 --> 00:36:05.920
<v Speaker 1>most elegant, the most pythonic approach from all these possibilities
