text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
still to define a function called get | 392.12 | 5.04 |
student and let get student do all of | 395.12 | 4.799 |
this work for us now theoretically get | 397.16 | 4.759 |
student could call get name and could | 399.919 | 3.68 |
call get house but because these | 401.919 | 4.161 |
functions are so short I think I'm okay | 403.599 | 4.521 |
with just defining one function called | 406.08 | 3.76 |
get student that similarly won't take | 408.12 | 3.56 |
any arguments but it's going to do two | 409.84 | 3.32 |
things it's going to get the student's | 411.68 | 3.6 |
name by prompting them with input as | 413.16 | 3.68 |
before and it's going to get the | 415.28 | 3.56 |
students house by also prompting them as | 416.84 | 3.079 |
before | 418.84 | 4.88 |
and then now hm I want to return the | 419.919 | 5.641 |
student but I think I might have painted | 423.72 | 4.199 |
myself into a corner here because I now | 425.56 | 4.759 |
have two variables name and house and | 427.919 | 4.12 |
yet up until now we've pretty much | 430.319 | 3.481 |
returned one or the other we've returned | 432.039 | 4.641 |
one value so any suggestions for how we | 433.8 | 4.959 |
can perhaps solve this problem that I | 436.68 | 4.959 |
just created for myself whereby I want | 438.759 | 5.521 |
to return really a student but I | 441.639 | 5.481 |
currently have a name variable and a | 444.28 | 4.639 |
house variable I'd minimally like to | 447.12 | 4.199 |
return both both of those I believe that | 448.919 | 4.921 |
we can return a dictionary includes the | 451.319 | 4.801 |
name and the house yeah so we absolutely | 453.84 | 4.28 |
could return a dictionary a dict object | 456.12 | 4.919 |
in Python whereby maybe one key is name | 458.12 | 4.759 |
one key is house and the values thereof | 461.039 | 3.241 |
are exactly the values of these | 462.879 | 3.961 |
variables we could totally do that uh I | 464.28 | 4 |
worry that that might be getting a | 466.84 | 3.039 |
little complicated I wonder if there's a | 468.28 | 4.56 |
simpler way instead any other instincts | 469.879 | 5.081 |
even if you're not sure it would work | 472.84 | 4.52 |
return both name and house return both | 474.96 | 4.16 |
name and house I I like the sound of | 477.36 | 3.36 |
that it sounds simple I don't have to | 479.12 | 3.079 |
figure out what a dictionary is going to | 480.72 | 4.039 |
look like and in fact this too would be | 482.199 | 4.28 |
a valid approach even if you've not seen | 484.759 | 3.801 |
this before it turns out in Python that | 486.479 | 5.041 |
you can kind of return multiple values | 488.56 | 4.88 |
but that's a bit of a white lie or we | 491.52 | 3.16 |
could take Muhammad's approach of | 493.44 | 2.879 |
actually returning a dictionary and | 494.68 | 3.639 |
putting multiple Keys therein so here | 496.319 | 3.641 |
again we have yet another example of how | 498.319 | 3.201 |
you can solve the same problem in at | 499.96 | 3.04 |
least two ways and I dare say we're | 501.52 | 4.359 |
about to see even more so one way you | 503 | 4.919 |
could solve this problem whereby you | 505.879 | 5.04 |
want to return multiple values would be | 507.919 | 5.441 |
to do something like this I could go | 510.919 | 5.441 |
ahead and literally return not just name | 513.36 | 5.4 |
but I could put a comma and also return | 516.36 | 4 |
house this is not necessarily something | 518.76 | 3.44 |
you can do in other languages if you | 520.36 | 3.359 |
have programmed in other languages | 522.2 | 3.68 |
before it depends on the language but it | 523.719 | 4.881 |
looks like thanks to this comma maybe I | 525.88 | 4.84 |
can in fact return two values as | 528.6 | 4.76 |
actually proposed well if I'm returning | 530.72 | 5.04 |
two values in this way on line 10 how do | 533.36 | 4.64 |
I get both values at the same time well | 535.76 | 4.4 |
there's a couple of ways let me go up to | 538 | 4.959 |
my main function I know minimally I'm | 540.16 | 4.239 |
going to have to change the get name and | 542.959 | 3.521 |
get house to get student but what am I | 544.399 | 5.241 |
going to store the return value in I | 546.48 | 5.28 |
think I could actually do this and we | 549.64 | 3.96 |
have seen this technique before where | 551.76 | 4.36 |
you can unpack so to speak sequences of | 553.6 | 4.6 |
values that are coming back and indeed | 556.12 | 4.52 |
consider this to be exactly that name | 558.2 | 4.319 |
comma house is some kind of sequence | 560.64 | 3.84 |
that I'm returning of values name comma | 562.519 | 3.88 |
house so if I want to unpack those and | 564.48 | 3.68 |
store the return values in two separate | 566.399 | 4.401 |
variables I can in fact use the commas | 568.16 | 4.6 |
on the left hand side of my assignment | 570.8 | 4.52 |
operator the equal sign to do just that | 572.76 | 4.84 |
now to be clear I don't need to call | 575.32 | 4.84 |
these variables name and house here I | 577.6 | 4.799 |
could simplify this and use just n here | 580.16 | 4.84 |
and H here and then I could return just | 582.399 | 5.921 |
n and H but I would argue that's not | 585 | 5.839 |
very uh clear to the reader as to what's | 588.32 | 4.28 |
going on so I think in this case even | 590.839 | 3.24 |
though it's a coincidence that I've used | 592.6 | 3.28 |
the same variable names in get student | 594.079 | 4.241 |
and get Main and in main it's a little | 595.88 | 4 |
more readable to someone like me so I'm | 598.32 | 3.759 |
going to leave it as is well let's go | 599.88 | 4.24 |
ahead and see now if this works let me | 602.079 | 3.601 |
clear my screen down here and run python | 604.12 | 3.76 |
of student. enter let's again type in | 605.68 | 4.64 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.