text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
eventually we added in things like name
6,632.88
4.359
and house for now let's assume that the
6,634.52
4.92
hat is much simpler than a student and
6,637.239
4.201
it only has sorting capabilities so I'm
6,639.44
3.6
not going to even pass any arguments
6,641.44
4.639
there too indeed let me assume that the
6,643.04
6.8
Sorting Hat has one Function One method
6,646.079
6.201
in inside of it called sort and so if I
6,649.84
6.839
do hat. sort quote unquote Harry let's
6,652.28
7.439
propose that that prints out what house
6,656.679
5.841
that student should be in so that's it
6,659.719
5.52
I'm going to encapsulate that is tuck
6,662.52
4.76
away inside of a hat class all of this
6,665.239
4.601
requisite functionality and I'm going to
6,667.28
5.2
print out onto the screen what hat uh
6,669.84
5.239
what house Harry belongs in all right
6,672.48
4.32
now I think I need to get into the weeds
6,675.079
3
of actually
6,676.8
3.919
initializing this class well let me go
6,678.079
5.12
ahead and do this if I don't care to
6,680.719
5.92
parameterize hat I just want to for
6,683.199
6.321
instance uh sort values let's go ahead
6,686.639
5.44
and Define this function sort first so
6,689.52
4.679
let's define sort as taking a first
6,692.079
4.201
argument self which is always going to
6,694.199
4.321
be the case when defining an instance
6,696.28
4.359
method as before but the sort method
6,698.52
4
clearly takes one argument from the
6,700.639
4.96
programmer me namely the student's name
6,702.52
4.639
and again we've seen this dichotomy
6,705.599
3.921
before even though I'm trying to pass in
6,707.159
4.801
one argument when I Define the method
6,709.52
4.679
it's got to take that many arguments
6,711.96
4.159
plus one more self which is always going
6,714.199
3.96
to be automatically passed in by python
6,716.119
5.12
first all right what do I want to do
6,718.159
4.56
well let's go ahead and do something
6,721.239
4.4
like this uh print quote unquote or
6,722.719
5.841
rather print this name how about quote
6,725.639
6.721
unquote is in quote unquote some house
6,728.56
5.36
I'm going to again use some placeholder
6,732.36
3
code for myself because I'm not quite
6,733.92
3.44
sure how to finish implementing this
6,735.36
4.08
Sorting Hat but I think that's enough to
6,737.36
4.52
just test where my code is at now let me
6,739.44
5.279
go ahead and run python of hat. and hit
6,741.88
5.319
enter and it looks like indeed Harry is
6,744.719
4.601
in some house we're not done yet because
6,747.199
3.761
it's clearly not doing anything
6,749.32
4.359
interesting but it at least is running
6,750.96
5.44
correctly with no errors well let's go
6,753.679
7.081
ahead now and decide where uh what house
6,756.4
5.64
Harry should actually be in by
6,760.76
2.72
introducing a bit of Randomness and
6,762.04
4.159
choosing a house randomly well I can do
6,763.48
4.4
this in a few ways let me go ahead and
6,766.199
4.641
do this I need to have a list of houses
6,767.88
5.08
somewhere so where can I put that I
6,770.84
3.359
could solve this problem in different
6,772.96
2.88
ways let me propose that I do this let
6,774.199
3.841
me Define a method called init as I've
6,775.84
4.319
done before that takes in self but no
6,778.04
4.28
other arguments and whenever the Sorting
6,780.159
4.56
Hat is instantiated let's do this let's
6,782.32
5.919
create a houses instance variable plural
6,784.719
7.4
that equals this list Gryffindor comma
6,788.239
7.92
Hufflepuff comma uh Ravenclaw comma
6,792.119
6.04
Slytherin so the exact same list that
6,796.159
4.401
we've used before and I'm storing it in
6,798.159
4.48
an instance variable inside of this
6,800.56
4.519
class I'm not taking any arguments
6,802.639
5.161
Beyond self in it but I just need this
6,805.079
5.681
list of values somewhere for instance so
6,807.8
5.24
what can I do here well let me go ahead
6,810.76
5.12
and replace some house with the actual
6,813.04
4.72
house well what could I do here well I
6,815.88
4.08
want to put a house there well let's go
6,817.76
4.359
ahead and create a variable called house
6,819.96
3.56
and if you think back to our discussion
6,822.119
4.321
of libraries in the random module there
6,823.52
5.679
is a function called choice that if you
6,826.44
6.36
pass in in a list of choices like self.
6,829.199
6.081
houses that will pick a random house out
6,832.8
4.68
of those four and then on line seven I
6,835.28
4.2
can pass it in if I want to tighten this
6,837.48
3.48
up let me just go ahead and highlight
6,839.48
3.599
that code get rid of the variable it's
6,840.96
4.08
technically unnecessary and because the
6,843.079
3.681
line of code is still pretty short I'm
6,845.04
3.88
okay with just putting it all in one
6,846.76
4
line but I could certainly use the
6,848.92
4.199
variable like I did a moment ago so what
6,850.76
5.8
have I done in my init function I have
6,853.119
7.6
defined a initialization of the object
6,856.56
6.159
that stores in self do houses the list
6,860.719
4.4
of four houses and then in sort I'm
6,862.719
4.201
accessing that same list but I'm
6,865.119
4.361
randomly choosing the set of houses
6,866.92
4.759
there now why have I done it in this way
6,869.48
4.639
this too is General convention anytime
6,871.679
4.201