text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
and let's do something super simple now | 183.04 | 4.16 |
let's just go ahead and print out an F | 185.239 | 4.801 |
string that says something like name | 187.2 | 5.24 |
from house just so that I can confirm | 190.04 | 4 |
that the contents of these variables are | 192.44 | 3.28 |
indeed as I expect I'm not going to do | 194.04 | 3.08 |
any error checking or trimming or | 195.72 | 2.72 |
anything like that for now I'm really | 197.12 | 2.72 |
just going to spit back out whatever the | 198.44 | 3.6 |
user just typed in all right let me go | 199.84 | 4.64 |
ahead and run python of student doy | 202.04 | 4.88 |
let's use our go-to like Harry as in | 204.48 | 4.88 |
Harry Potter from Gryffindor and when I | 206.92 | 4.519 |
hit ENT now let's see if I see that | 209.36 | 4.72 |
Harry from Gryffindor is indeed the case | 211.439 | 4.121 |
all right so I think we have a working | 214.08 | 3.56 |
program at this point but let's now | 215.56 | 3.759 |
introduce some of those Lessons Learned | 217.64 | 3.4 |
way back from week zero where we started | 219.319 | 3.401 |
writing our own functions not | 221.04 | 4 |
necessarily because it solves the | 222.72 | 4.079 |
problem more correctly I dare say this | 225.04 | 4.399 |
is correct as is but it begins to give | 226.799 | 5.121 |
us building blocks that we can extend so | 229.439 | 4.8 |
as to solve more complicated programs so | 231.92 | 5.12 |
let me go back up to student. and let's | 234.239 | 4.64 |
go ahead now and do this let's put the | 237.04 | 4.119 |
entire log IC I just wrote inside of our | 238.879 | 4.2 |
typical method called Main and let me | 241.159 | 3.72 |
indent those three lines so that at | 243.079 | 3.641 |
least they're now combined into one main | 244.879 | 5.161 |
method but instead of using input on | 246.72 | 5.76 |
line two and input on line three why | 250.04 | 3.72 |
don't we go ahead and assume for the | 252.48 | 2.72 |
moment that we've got some function | 253.76 | 3.719 |
called get name in the world and let's | 255.2 | 3.52 |
go ahead and assume we've got another | 257.479 | 2.841 |
function like get house in the world | 258.72 | 3.6 |
that don't take parameters but their | 260.32 | 4 |
purpose in life is by their named going | 262.32 | 4.08 |
to be to get the user's name and to get | 264.32 | 4.48 |
their user's house respectively and then | 266.4 | 4.48 |
I'm going to print out the exact same F | 268.8 | 4.119 |
string as before I of course need to | 270.88 | 3.72 |
implement these functions now so let me | 272.919 | 3.401 |
go lower in my file and Define a | 274.6 | 4.2 |
function called getor name nothing in | 276.32 | 3.84 |
these parentheses because it's not going | 278.8 | 3.2 |
to take a parameter and I'm going to go | 280.16 | 4.16 |
ahead and do something like name equals | 282 | 4.28 |
input quote unquote name just like | 284.32 | 3.28 |
before and then I'm going to go ahead | 286.28 | 3.52 |
and return name so it's a super simple | 287.6 | 4.8 |
function but it's a an abstraction I now | 289.8 | 4.679 |
have a function called get name whose | 292.4 | 3.48 |
implementation details I don't have to | 294.479 | 3.041 |
care about anymore I just know that the | 295.88 | 3.36 |
function exists and I can tighten this | 297.52 | 3.76 |
up in in fact I don't really need a name | 299.24 | 4.12 |
variable on line 8 if I'm immediately | 301.28 | 3.639 |
going to return that same name variable | 303.36 | 3.8 |
on line 9 so let me just tighten this up | 304.919 | 3.521 |
a little bit even though it doesn't | 307.16 | 3.039 |
change the functionality and just | 308.44 | 4.24 |
immediately return the return value of | 310.199 | 5.641 |
the inputs uh function call here let's | 312.68 | 5.72 |
do something very similar now for get | 315.84 | 4.16 |
house which will similarly take no | 318.4 | 3.12 |
arguments I'm going to go ahead and | 320 | 3.72 |
return the return value of input this | 321.52 | 4 |
time prompting the user for their house | 323.72 | 4.199 |
and I need one final detail at the very | 325.52 | 4.64 |
bottom let's continue our habit of doing | 327.919 | 5.041 |
if the name of this file equals equals | 330.16 | 5.479 |
quote unquote main then let's go ahead | 332.96 | 4.84 |
and actually call Main and recall that | 335.639 | 3.801 |
we have that in place so that if this | 337.8 | 3.519 |
eventually becomes part of a module a | 339.44 | 3.759 |
library of sorts I don't accidentally | 341.319 | 5.201 |
call Main blindly I only do it if I mean | 343.199 | 5.881 |
to run main from the command line on | 346.52 | 4.88 |
this file all right so if I didn't make | 349.08 | 4.52 |
any mistakes here let me go ahead and in | 351.4 | 4.04 |
my terminal window again run python of | 353.6 | 5.039 |
student. piy enter let's type in Harry | 355.44 | 6.68 |
enter let's type in Gryffindor enter and | 358.639 | 5.961 |
we're set Harry from Gryffindor seems to | 362.12 | 4.479 |
still be working so we haven't really | 364.6 | 4.879 |
solved the problem any more correctly | 366.599 | 4.88 |
but I've laid the foundation to maybe | 369.479 | 3.641 |
now do some more interesting things | 371.479 | 3.401 |
because I've have these building blocks | 373.12 | 4.84 |
in place all right but let me propose | 374.88 | 5.319 |
that we could be doing this a little bit | 377.96 | 4.88 |
differently get name get house is fine | 380.199 | 4 |
but at the end of the day I'm really | 382.84 | 3.6 |
trying to get a student from the user I | 384.199 | 4.44 |
want their name and their house not just | 386.44 | 3.68 |
one or the other | 388.639 | 3.481 |
so maybe it would be a little cleaner | 390.12 | 5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.