text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
the stir method taking in self as its | 9,388.479 | 4.761 |
sole argument here and let's just return | 9,391.12 | 4.76 |
a very simple string that just reveals | 9,393.24 | 4 |
what's in the vault so I'm going to | 9,395.88 | 4.599 |
return a formatted F string uh inside of | 9,397.24 | 6.079 |
which is self. gallion and then the word | 9,400.479 | 5.281 |
uh gallion so I know which those are uh | 9,403.319 | 4.361 |
then then let's do self. sickles and | 9,405.76 | 4.04 |
let's output the word sickles and then | 9,407.68 | 4.12 |
lastly let's output self. canuts and | 9,409.8 | 4.559 |
then canuts here so I know in this | 9,411.8 | 5.479 |
string just how many of each of those uh | 9,414.359 | 5.481 |
coins I have in this particular family's | 9,417.279 | 4.961 |
Vault all right let me go ahead and run | 9,419.84 | 4.599 |
python of vault. py changing nothing | 9,422.24 | 4.6 |
else except the stir method and now we | 9,424.439 | 4.88 |
see indeed that Harry has 100 gallions | 9,426.84 | 5.32 |
50 sickles and 25 canuts all right well | 9,429.319 | 4.641 |
let's do one thing more here below that | 9,432.16 | 3.72 |
let's go ahead and Define a Weasley | 9,433.96 | 4 |
variable and Ron never seemed to have | 9,435.88 | 4 |
quite as much uh money in the vault as | 9,437.96 | 3.92 |
did Harry so let's say that the Weasley | 9,439.88 | 4.559 |
Vault will have 25 50 and a 100 so I'll | 9,441.88 | 3.96 |
just reverse the order of those | 9,444.439 | 3.96 |
denominations uh rather than Harry's 100 | 9,445.84 | 4.76 |
5025 and now let me go ahead and print | 9,448.399 | 5.92 |
Weasley like this and let's go ahead and | 9,450.6 | 5.679 |
clear my terminal window run python of | 9,454.319 | 4.321 |
vaulty this time that stir method will | 9,456.279 | 4.881 |
be invoked twice once for each of those | 9,458.64 | 4.88 |
Vault objects and we'll see indeed that | 9,461.16 | 4.96 |
the first one for Harry's got 150 and2 | 9,463.52 | 6.08 |
respectively versus runs 25 50 and 100 | 9,466.12 | 5.56 |
respectively but now let's do something | 9,469.6 | 4.32 |
interesting suppose that you wanted to | 9,471.68 | 4.719 |
combine the contents of two vaults be it | 9,473.92 | 4.16 |
Harry's and Ron's or any other two | 9,476.399 | 4.481 |
people how would you go about doing this | 9,478.08 | 5.56 |
in code well if I wanted to combine the | 9,480.88 | 5.04 |
vaults for someone I could do this well | 9,483.64 | 5.04 |
I could do gallion equals let's do | 9,485.92 | 7.08 |
Potter do gallion uh plus Weasley do | 9,488.68 | 6.48 |
gallion that gives me a variable called | 9,493 | 4.479 |
gallions that has the sum of Harry and | 9,495.16 | 5.4 |
Ron's gallions let's next do sickles | 9,497.479 | 6.92 |
equals potter. sickles plus Weasley | 9,500.56 | 6.799 |
Doles and then lastly let's do canuts | 9,504.399 | 6.88 |
equals potter. canuts plus Weasley do | 9,507.359 | 5.681 |
canuts I've got three variables what can | 9,511.279 | 3.441 |
I now do with these values well let's | 9,513.04 | 4.56 |
create a third a new Vault uh total will | 9,514.72 | 4.8 |
be the name of this variable equals a | 9,517.6 | 4.679 |
new Vault capital V notice and now let's | 9,519.52 | 4.24 |
pass in those three new variables | 9,522.279 | 5.281 |
gallions sickles and Kuts and that's it | 9,523.76 | 5.96 |
and let's print out this total Vault so | 9,527.56 | 4.04 |
we should now see three vaults one for | 9,529.72 | 4.24 |
Harry for Ron and the combination the | 9,531.6 | 4.08 |
addition of the two let me go ahead and | 9,533.96 | 4.08 |
rerun python of vaulty and there we have | 9,535.68 | 7.36 |
it uh what was 15025 and 2550 and 100 | 9,538.04 | 9.08 |
combined through addition now is 125 100 | 9,543.04 | 6.439 |
125 so pretty straightforward using | 9,547.12 | 3.92 |
techniques from weeks ago where we're | 9,549.479 | 3.401 |
just declaring a few new variables and | 9,551.04 | 4.8 |
doing some addition but wouldn't it be | 9,552.88 | 5.32 |
cool if I could do something like this | 9,555.84 | 3.88 |
wouldn't it be cool if I could just | 9,558.2 | 4.079 |
somehow not manually create my own Vault | 9,559.72 | 4.84 |
and do all of this annoying math up here | 9,562.279 | 4.521 |
what if I could just do Potter plus | 9,564.56 | 4.96 |
Weasley and get rid of all of this logic | 9,566.8 | 5.36 |
here like wouldn't it be nice if I | 9,569.52 | 6.48 |
overload the operator no we know as plus | 9,572.16 | 6.48 |
just like stir does just like list does | 9,576 | 5.92 |
to allow me to add two vaults together | 9,578.64 | 6.08 |
on the left and the right well it turns | 9,581.92 | 5.399 |
out in Python on and through operator | 9,584.72 | 5.48 |
overla there is a way to do just this if | 9,587.319 | 4.96 |
you consult the documentation there are | 9,590.2 | 4.52 |
there's this and so many other special | 9,592.279 | 4.841 |
methods that come with classes the third | 9,594.72 | 5.12 |
one we'll see here is this one here | 9,597.12 | 5.4 |
underscore uncore add underscore | 9,599.84 | 4.4 |
underscore and you'll see that it very | 9,602.52 | 3 |
generically is described in the | 9,604.24 | 3.48 |
documentation is working for any object | 9,605.52 | 4.32 |
be it a vault or a stir or a list or | 9,607.72 | 3.88 |
something else by convention it's going | 9,609.84 | 3.559 |
to take a first argument called self and | 9,611.6 | 2.92 |
then it's going to take some other | 9,613.399 | 4.361 |
argument by convention called Other Self | 9,614.52 | 5.04 |
in effect is going to be referring to | 9,617.76 | 3.76 |
whatever object is on the left of a plus | 9,619.56 | 4.12 |
sign other is going to be referring to | 9,621.52 | 3.959 |
whatever is on the right hand side of a | 9,623.68 | 4.08 |
plus sign thereby giving us a way of | 9,625.479 | 4.96 |
describing in code the operand on the | 9,627.76 | 4.92 |
left and the operand on the right of the | 9,630.439 | 5.721 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.