[ { "text": "so", "start": 5.6, "duration": 7.639 }, { "text": "[Music]", "start": 7.35, "duration": 5.889 }, { "text": "[Music]", "start": 15.28, "duration": 6.869 }, { "text": "all right this is cs50s introduction to", "start": 24.16, "duration": 4.959 }, { "text": "programming with python my name is david", "start": 27.119, "duration": 4.4 }, { "text": "maylin and this is our week on libraries", "start": 29.119, "duration": 5.361 }, { "text": "so libraries are generally files of code", "start": 31.519, "duration": 4.481 }, { "text": "that other people have written that you", "start": 34.48, "duration": 3.919 }, { "text": "can use in your own programs or a", "start": 36.0, "duration": 4.079 }, { "text": "library's code that you've written that", "start": 38.399, "duration": 3.121 }, { "text": "you can use in your own program but", "start": 40.079, "duration": 3.281 }, { "text": "maybe not just this program but another", "start": 41.52, "duration": 4.719 }, { "text": "and another as well so python supports", "start": 43.36, "duration": 5.12 }, { "text": "exactly this idea this ability to share", "start": 46.239, "duration": 4.64 }, { "text": "code with others share code across your", "start": 48.48, "duration": 4.32 }, { "text": "own projects and it does so by way of", "start": 50.879, "duration": 4.481 }, { "text": "what it calls module a module in python", "start": 52.8, "duration": 5.12 }, { "text": "is just a library that typically has one", "start": 55.36, "duration": 4.879 }, { "text": "or more functions or other features", "start": 57.92, "duration": 4.479 }, { "text": "built into it generally the purpose of a", "start": 60.239, "duration": 4.481 }, { "text": "library or a module specifically is to", "start": 62.399, "duration": 4.4 }, { "text": "encourage reusability of code if you", "start": 64.72, "duration": 4.48 }, { "text": "find yourself using the same types of", "start": 66.799, "duration": 4.0 }, { "text": "functions again and again the same", "start": 69.2, "duration": 3.52 }, { "text": "functionality if you find yourself", "start": 70.799, "duration": 4.881 }, { "text": "copying and pasting from an old project", "start": 72.72, "duration": 4.8 }, { "text": "into your new project odds are there's", "start": 75.68, "duration": 4.4 }, { "text": "an opportunity there to factor out that", "start": 77.52, "duration": 4.48 }, { "text": "code that you keep copying and pasting", "start": 80.08, "duration": 4.32 }, { "text": "that you keep reusing and put it into a", "start": 82.0, "duration": 4.799 }, { "text": "library that you can then load into your", "start": 84.4, "duration": 4.48 }, { "text": "programs moving forward so as to not", "start": 86.799, "duration": 3.601 }, { "text": "just copy and paste it and have all", "start": 88.88, "duration": 3.36 }, { "text": "these different copies all over", "start": 90.4, "duration": 3.759 }, { "text": "so what are some of the modules or", "start": 92.24, "duration": 3.919 }, { "text": "libraries that python comes with well", "start": 94.159, "duration": 4.241 }, { "text": "python comes with a random library", "start": 96.159, "duration": 3.92 }, { "text": "literally which is to say that when you", "start": 98.4, "duration": 3.84 }, { "text": "install the python interpreter on your", "start": 100.079, "duration": 4.641 }, { "text": "mac or pc or somewhere in the cloud not", "start": 102.24, "duration": 4.08 }, { "text": "only do you get python you get a whole", "start": 104.72, "duration": 3.84 }, { "text": "bunch of modules as well now these", "start": 106.32, "duration": 4.079 }, { "text": "modules provide you with functions that", "start": 108.56, "duration": 4.0 }, { "text": "you don't have access to just by default", "start": 110.399, "duration": 4.881 }, { "text": "like you do print and input print and", "start": 112.56, "duration": 4.72 }, { "text": "input and other such functions just work", "start": 115.28, "duration": 4.56 }, { "text": "in python but sometimes functions are", "start": 117.28, "duration": 4.879 }, { "text": "tucked away in these modules so you have", "start": 119.84, "duration": 4.4 }, { "text": "to be more deliberate about loading them", "start": 122.159, "duration": 4.481 }, { "text": "into the computer's memory so somewhere", "start": 124.24, "duration": 3.92 }, { "text": "on the computer's hard drive once you've", "start": 126.64, "duration": 3.679 }, { "text": "installed python there is also it turns", "start": 128.16, "duration": 5.439 }, { "text": "out a file probably called random.pi", "start": 130.319, "duration": 5.121 }, { "text": "that someone else wrote probably long", "start": 133.599, "duration": 4.081 }, { "text": "ago but that you have access to and in", "start": 135.44, "duration": 4.48 }, { "text": "that random.pi file there's probably one", "start": 137.68, "duration": 4.16 }, { "text": "or more functions that you yourself can", "start": 139.92, "duration": 5.2 }, { "text": "use in order to do things randomly that", "start": 141.84, "duration": 5.759 }, { "text": "is to say how could you flip a coin in a", "start": 145.12, "duration": 4.8 }, { "text": "program in python how could you pick a a", "start": 147.599, "duration": 5.28 }, { "text": "random number between 1 and 10 in python", "start": 149.92, "duration": 4.48 }, { "text": "well you need a bit of randomness and", "start": 152.879, "duration": 3.121 }, { "text": "while you could figure out", "start": 154.4, "duration": 3.6 }, { "text": "mathematically how to write functions", "start": 156.0, "duration": 4.4 }, { "text": "like that yourself it's a lot easier to", "start": 158.0, "duration": 4.0 }, { "text": "stand on the shoulders of others who've", "start": 160.4, "duration": 3.52 }, { "text": "already solved that problem for you so", "start": 162.0, "duration": 3.84 }, { "text": "you can focus on the problem that you", "start": 163.92, "duration": 4.399 }, { "text": "yourself want to solve so for", "start": 165.84, "duration": 5.119 }, { "text": "documentation on most any python module", "start": 168.319, "duration": 4.56 }, { "text": "you go to the official python docs and", "start": 170.959, "duration": 3.761 }, { "text": "you go to a url like this where the", "start": 172.879, "duration": 4.0 }, { "text": "documentation for that specific module", "start": 174.72, "duration": 4.159 }, { "text": "lives and within the documentation", "start": 176.879, "duration": 3.521 }, { "text": "you'll see a list of the functions or", "start": 178.879, "duration": 3.44 }, { "text": "other functionality that some module", "start": 180.4, "duration": 4.479 }, { "text": "provides but how do you go about loading", "start": 182.319, "duration": 4.0 }, { "text": "a module", "start": 184.879, "duration": 3.44 }, { "text": "into your own program so that you can", "start": 186.319, "duration": 4.321 }, { "text": "use the functions in that module well we", "start": 188.319, "duration": 4.801 }, { "text": "need a new keyword in python and namely", "start": 190.64, "duration": 5.92 }, { "text": "its import the import keyword in python", "start": 193.12, "duration": 6.8 }, { "text": "allows you to import the contents of the", "start": 196.56, "duration": 4.72 }, { "text": "functions from", "start": 199.92, "duration": 4.319 }, { "text": "some module in python well how might i", "start": 201.28, "duration": 4.879 }, { "text": "go about using this in practice well let", "start": 204.239, "duration": 4.161 }, { "text": "me propose that there exists in that", "start": 206.159, "duration": 4.881 }, { "text": "random module this function among others", "start": 208.4, "duration": 4.24 }, { "text": "so i have copied and pasted from the", "start": 211.04, "duration": 3.199 }, { "text": "documentation", "start": 212.64, "duration": 2.48 }, { "text": "this", "start": 214.239, "duration": 3.92 }, { "text": "summary of a function called choice now", "start": 215.12, "duration": 6.56 }, { "text": "the function exists in the random module", "start": 218.159, "duration": 6.08 }, { "text": "so to speak not a random module the", "start": 221.68, "duration": 4.639 }, { "text": "random module and so generally the", "start": 224.239, "duration": 4.0 }, { "text": "documentation describes it fully like", "start": 226.319, "duration": 2.601 }, { "text": "this", "start": 228.239, "duration": 2.64 }, { "text": "random.choice is how you would", "start": 228.92, "duration": 3.399 }, { "text": "technically call this function though", "start": 230.879, "duration": 3.28 }, { "text": "we'll see alternatives to that in", "start": 232.319, "duration": 4.161 }, { "text": "parentheses there is a parameter called", "start": 234.159, "duration": 5.28 }, { "text": "seq for sequence and sequence generally", "start": 236.48, "duration": 5.28 }, { "text": "means a list or something that is list", "start": 239.439, "duration": 4.16 }, { "text": "like if you have a list of numbers or", "start": 241.76, "duration": 3.44 }, { "text": "strings or anything else and the", "start": 243.599, "duration": 3.84 }, { "text": "documentation elaborates well how can i", "start": 245.2, "duration": 4.08 }, { "text": "go about using this function to solve", "start": 247.439, "duration": 3.761 }, { "text": "perhaps a familiar problem well let me", "start": 249.28, "duration": 4.0 }, { "text": "go ahead and open up vs code here and", "start": 251.2, "duration": 3.759 }, { "text": "let me propose that we implement a", "start": 253.28, "duration": 4.4 }, { "text": "program that simulates flipping a coin a", "start": 254.959, "duration": 5.68 }, { "text": "coin that in the us heads heads or tails", "start": 257.68, "duration": 6.079 }, { "text": "the idea of which is to pick a decision", "start": 260.639, "duration": 6.081 }, { "text": "with 50 50 probability 50 probability of", "start": 263.759, "duration": 5.681 }, { "text": "heads 50 probability of tails or you can", "start": 266.72, "duration": 4.72 }, { "text": "use some other mechanism like that well", "start": 269.44, "duration": 4.0 }, { "text": "let me go ahead and open a program with", "start": 271.44, "duration": 4.479 }, { "text": "code called generate dot pi because i", "start": 273.44, "duration": 4.08 }, { "text": "want to start generating a whole bunch", "start": 275.919, "duration": 3.601 }, { "text": "of random information the first of which", "start": 277.52, "duration": 3.92 }, { "text": "is just going to be a coin toss now how", "start": 279.52, "duration": 4.399 }, { "text": "do i go about using that function well i", "start": 281.44, "duration": 5.12 }, { "text": "first have to import the random library", "start": 283.919, "duration": 4.161 }, { "text": "so literally the first or among the", "start": 286.56, "duration": 4.16 }, { "text": "first lines of my file should be import", "start": 288.08, "duration": 4.8 }, { "text": "random and that just gives me access to", "start": 290.72, "duration": 4.4 }, { "text": "all of the functions in that specific", "start": 292.88, "duration": 5.84 }, { "text": "module now suppose i want to flip a coin", "start": 295.12, "duration": 6.32 }, { "text": "well i can do random dot choice per the", "start": 298.72, "duration": 4.8 }, { "text": "documentation a moment ago and that", "start": 301.44, "duration": 4.16 }, { "text": "again takes a sequence what's a sequence", "start": 303.52, "duration": 3.6 }, { "text": "it's a list or something that's list", "start": 305.6, "duration": 3.68 }, { "text": "like and we know about lists we've used", "start": 307.12, "duration": 4.079 }, { "text": "lists to iterate over numbers we've used", "start": 309.28, "duration": 3.28 }, { "text": "lists to iterate over students at", "start": 311.199, "duration": 3.361 }, { "text": "hogwarts let's go ahead now and let's", "start": 312.56, "duration": 4.639 }, { "text": "iterate over just a list of two sides of", "start": 314.56, "duration": 6.079 }, { "text": "a coin heads quote unquote or tails now", "start": 317.199, "duration": 5.121 }, { "text": "i could call these anything i want these", "start": 320.639, "duration": 4.081 }, { "text": "are my strings i just want to simulate a", "start": 322.32, "duration": 3.84 }, { "text": "tossing a coin so i'm just going to say", "start": 324.72, "duration": 3.919 }, { "text": "in all lower case heads and tails but", "start": 326.16, "duration": 4.96 }, { "text": "notice the syntax i have heads and tails", "start": 328.639, "duration": 3.84 }, { "text": "and double quotes that's because they're", "start": 331.12, "duration": 3.2 }, { "text": "strings i could also use single quotes", "start": 332.479, "duration": 3.521 }, { "text": "so long as i'm consistent there's a", "start": 334.32, "duration": 3.2 }, { "text": "comma between them which means the list", "start": 336.0, "duration": 4.24 }, { "text": "has two elements there's square brackets", "start": 337.52, "duration": 4.64 }, { "text": "to the right and the left which", "start": 340.24, "duration": 3.92 }, { "text": "indicates that this is indeed a list", "start": 342.16, "duration": 4.08 }, { "text": "that's the syntax recall for defining a", "start": 344.16, "duration": 4.08 }, { "text": "list in python and then lastly there's", "start": 346.24, "duration": 3.36 }, { "text": "something more familiar there's the", "start": 348.24, "duration": 3.36 }, { "text": "parentheses outside of those square", "start": 349.6, "duration": 3.039 }, { "text": "brackets but those are just the", "start": 351.6, "duration": 3.12 }, { "text": "parentheses that belong to the choice", "start": 352.639, "duration": 4.801 }, { "text": "function and specify where its parameter", "start": 354.72, "duration": 5.28 }, { "text": "gets passed in but again unlike past", "start": 357.44, "duration": 6.0 }, { "text": "functions i have to specify what module", "start": 360.0, "duration": 5.52 }, { "text": "this function is in at least for now and", "start": 363.44, "duration": 4.64 }, { "text": "so i do random dot choice to call this", "start": 365.52, "duration": 4.32 }, { "text": "specific function all right well it's", "start": 368.08, "duration": 3.92 }, { "text": "one thing to flip a coin picking between", "start": 369.84, "duration": 3.52 }, { "text": "those with 50", "start": 372.0, "duration": 2.4 }, { "text": "probability and that's what", "start": 373.36, "duration": 3.679 }, { "text": "random.choice does it takes in a list", "start": 374.4, "duration": 4.639 }, { "text": "and it returns to one of those values", "start": 377.039, "duration": 4.321 }, { "text": "randomly with equal probability because", "start": 379.039, "duration": 4.0 }, { "text": "i've passed in two items i've got a 50", "start": 381.36, "duration": 4.08 }, { "text": "50 chance if i passed in three items", "start": 383.039, "duration": 4.801 }, { "text": "it'd be a 33 chance for each of those", "start": 385.44, "duration": 4.479 }, { "text": "items and so forth python does the math", "start": 387.84, "duration": 4.24 }, { "text": "for you but i want to store the value of", "start": 389.919, "duration": 3.601 }, { "text": "this in a variable so let's define a", "start": 392.08, "duration": 4.0 }, { "text": "variable called coin equals whatever the", "start": 393.52, "duration": 4.72 }, { "text": "return value is so this is indeed like", "start": 396.08, "duration": 3.92 }, { "text": "flipping a coin i'm going to store in a", "start": 398.24, "duration": 4.32 }, { "text": "variable called coin whatever that value", "start": 400.0, "duration": 4.319 }, { "text": "is heads or tails and now just so i can", "start": 402.56, "duration": 3.6 }, { "text": "see what's going on let's go ahead and", "start": 404.319, "duration": 4.88 }, { "text": "print out the value of that string coin", "start": 406.16, "duration": 4.4 }, { "text": "all right let me go ahead now and run", "start": 409.199, "duration": 3.201 }, { "text": "this program in my terminal window", "start": 410.56, "duration": 5.28 }, { "text": "python of generate dot pi enter and it", "start": 412.4, "duration": 5.04 }, { "text": "looks like the first coin toss was the", "start": 415.84, "duration": 4.479 }, { "text": "heads let's go ahead and run it again", "start": 417.44, "duration": 4.56 }, { "text": "and it looks like it was heads again", "start": 420.319, "duration": 3.041 }, { "text": "maybe you want to chime into the chat", "start": 422.0, "duration": 3.039 }, { "text": "here if i run it a third time what's it", "start": 423.36, "duration": 3.36 }, { "text": "going to be this time if you want to", "start": 425.039, "duration": 4.72 }, { "text": "type your thoughts in the chat", "start": 426.72, "duration": 4.8 }, { "text": "you might think there's a bug here but", "start": 429.759, "duration": 4.56 }, { "text": "this is probability in action if i go", "start": 431.52, "duration": 5.04 }, { "text": "ahead and hit enter a third time there", "start": 434.319, "duration": 4.641 }, { "text": "it's actually now tails and again tails", "start": 436.56, "duration": 4.4 }, { "text": "and again tails and again tails and", "start": 438.96, "duration": 4.639 }, { "text": "again tails and again heads now if we", "start": 440.96, "duration": 4.56 }, { "text": "did this an infinite number of times it", "start": 443.599, "duration": 4.241 }, { "text": "would indeed work out to be 50 50. if we", "start": 445.52, "duration": 4.56 }, { "text": "only do it a few times it might not work", "start": 447.84, "duration": 3.84 }, { "text": "out as cleanly but that's how", "start": 450.08, "duration": 3.679 }, { "text": "probabilities indeed work all right so", "start": 451.68, "duration": 4.48 }, { "text": "i've got that now working could i have", "start": 453.759, "duration": 3.761 }, { "text": "implemented this in a different way well", "start": 456.16, "duration": 3.039 }, { "text": "let me show you an alternative to", "start": 457.52, "duration": 4.799 }, { "text": "actually using the import keyword alone", "start": 459.199, "duration": 5.44 }, { "text": "and let me introduce the keyword from in", "start": 462.319, "duration": 5.361 }, { "text": "python so from is a keyword in python", "start": 464.639, "duration": 4.96 }, { "text": "that you can use when importing", "start": 467.68, "duration": 4.4 }, { "text": "functions from a module but it allows", "start": 469.599, "duration": 4.401 }, { "text": "you to be a little more specific than", "start": 472.08, "duration": 4.08 }, { "text": "import alone so if i go back to my code", "start": 474.0, "duration": 3.759 }, { "text": "here it's worth noting that what", "start": 476.16, "duration": 4.24 }, { "text": "technically i'm doing here by importing", "start": 477.759, "duration": 4.88 }, { "text": "random is i'm technically importing", "start": 480.4, "duration": 4.88 }, { "text": "everything that's in that module so not", "start": 482.639, "duration": 5.441 }, { "text": "just the function called random.choice", "start": 485.28, "duration": 4.88 }, { "text": "but a few other functions as well so", "start": 488.08, "duration": 3.519 }, { "text": "instead of using this line of code at", "start": 490.16, "duration": 3.439 }, { "text": "the top of my file import random which", "start": 491.599, "duration": 3.841 }, { "text": "will technically give me access to all", "start": 493.599, "duration": 4.401 }, { "text": "of the contents they're in a downside of", "start": 495.44, "duration": 5.24 }, { "text": "that is that i have to type in", "start": 498.0, "duration": 4.639 }, { "text": "random.choicerandom.this random.that", "start": 500.68, "duration": 4.12 }, { "text": "because all of the functions i'm calling", "start": 502.639, "duration": 4.161 }, { "text": "have to be associated with the scope of", "start": 504.8, "duration": 4.0 }, { "text": "that module well suppose that i just", "start": 506.8, "duration": 3.839 }, { "text": "want to call the function as its name", "start": 508.8, "duration": 3.919 }, { "text": "choice i can do that as well let me", "start": 510.639, "duration": 4.801 }, { "text": "replace this first line here with from", "start": 512.719, "duration": 5.841 }, { "text": "random import choice and what this does", "start": 515.44, "duration": 5.519 }, { "text": "effectively is it loads the function's", "start": 518.56, "duration": 5.44 }, { "text": "name choice into my current namespace", "start": 520.959, "duration": 5.521 }, { "text": "into the scope of the file i'm working", "start": 524.0, "duration": 4.64 }, { "text": "in what that means is that i now no", "start": 526.48, "duration": 4.56 }, { "text": "longer have to specify which choice", "start": 528.64, "duration": 4.72 }, { "text": "function i mean i can just say choice", "start": 531.04, "duration": 4.32 }, { "text": "and so it loads it into the local", "start": 533.36, "duration": 3.599 }, { "text": "namespace that is into my local", "start": 535.36, "duration": 4.08 }, { "text": "vocabulary if you will so i can just now", "start": 536.959, "duration": 6.0 }, { "text": "say choice this might be advantageous", "start": 539.44, "duration": 6.0 }, { "text": "in what cases do you think when might", "start": 542.959, "duration": 4.88 }, { "text": "you want to import the name of the", "start": 545.44, "duration": 5.04 }, { "text": "function explicitly like this as opposed", "start": 547.839, "duration": 4.641 }, { "text": "to just saying random.choice", "start": 550.48, "duration": 4.24 }, { "text": "random.choice throughout your code when", "start": 552.48, "duration": 3.919 }, { "text": "calling a function", "start": 554.72, "duration": 4.08 }, { "text": "any instincts here for this alternative", "start": 556.399, "duration": 3.521 }, { "text": "import", "start": 558.8, "duration": 2.64 }, { "text": "using from", "start": 559.92, "duration": 3.76 }, { "text": "um hello i'm mohammed ahmar from egypt", "start": 561.44, "duration": 5.28 }, { "text": "and maybe if we have a variable that", "start": 563.68, "duration": 5.599 }, { "text": "its name is basically like choice if i", "start": 566.72, "duration": 4.48 }, { "text": "have a variable called the choice so i", "start": 569.279, "duration": 3.761 }, { "text": "need to differentiate which trace i", "start": 571.2, "duration": 3.04 }, { "text": "choose so", "start": 573.04, "duration": 3.6 }, { "text": "i'm gonna choose random.choice", "start": 574.24, "duration": 4.0 }, { "text": "yeah really good instincts by using the", "start": 576.64, "duration": 3.84 }, { "text": "first approach by just importing random", "start": 578.24, "duration": 3.92 }, { "text": "you're making sure that all of its", "start": 580.48, "duration": 4.479 }, { "text": "contents are associated with are scoped", "start": 582.16, "duration": 5.44 }, { "text": "to the random module so that you can", "start": 584.959, "duration": 4.32 }, { "text": "have your own choice function you can", "start": 587.6, "duration": 3.679 }, { "text": "have your own choice variable you can", "start": 589.279, "duration": 4.081 }, { "text": "use the same names as all of the", "start": 591.279, "duration": 3.841 }, { "text": "functions or variables that are stored", "start": 593.36, "duration": 3.52 }, { "text": "inside of that file without them", "start": 595.12, "duration": 3.68 }, { "text": "colliding so to speak and this is a good", "start": 596.88, "duration": 4.24 }, { "text": "thing in older languages it was the case", "start": 598.8, "duration": 4.159 }, { "text": "that if you imported someone's library", "start": 601.12, "duration": 3.44 }, { "text": "you better hope that you're not using", "start": 602.959, "duration": 3.921 }, { "text": "the same functions or variables as they", "start": 604.56, "duration": 3.92 }, { "text": "are because you might in fact have some", "start": 606.88, "duration": 3.68 }, { "text": "kind of conflict python and certain", "start": 608.48, "duration": 3.919 }, { "text": "other languages allow you to scope the", "start": 610.56, "duration": 3.839 }, { "text": "names of those functions and variables", "start": 612.399, "duration": 3.841 }, { "text": "to the file or the module that they come", "start": 614.399, "duration": 4.0 }, { "text": "from so that's a good thing but honestly", "start": 616.24, "duration": 4.88 }, { "text": "this is such a short program or", "start": 618.399, "duration": 4.721 }, { "text": "equivalently maybe i'm using the choice", "start": 621.12, "duration": 4.24 }, { "text": "function in so many places", "start": 623.12, "duration": 4.12 }, { "text": "calling", "start": 625.36, "duration": 2.88 }, { "text": "random.choicerandom.choicerandom.choice", "start": 627.24, "duration": 2.599 }, { "text": "it's just making my code longer and", "start": 628.24, "duration": 4.08 }, { "text": "longer and longer marginally so but it's", "start": 629.839, "duration": 4.961 }, { "text": "just getting ugly and annoying i can", "start": 632.32, "duration": 4.72 }, { "text": "simply import choice and now tighten up", "start": 634.8, "duration": 4.159 }, { "text": "my code a little bit so as with so many", "start": 637.04, "duration": 3.6 }, { "text": "decisions in the past there's not", "start": 638.959, "duration": 3.601 }, { "text": "necessarily one right approach or", "start": 640.64, "duration": 3.68 }, { "text": "another it depends but i think for those", "start": 642.56, "duration": 3.76 }, { "text": "very reasons sometimes it's better to do", "start": 644.32, "duration": 4.32 }, { "text": "what we did the first time which is only", "start": 646.32, "duration": 4.959 }, { "text": "import the module so as to retain the", "start": 648.64, "duration": 5.04 }, { "text": "scope therein well let me propose that", "start": 651.279, "duration": 4.161 }, { "text": "we transition to another function that", "start": 653.68, "duration": 4.08 }, { "text": "comes with python's random module and", "start": 655.44, "duration": 4.32 }, { "text": "that's this here from the documentation", "start": 657.76, "duration": 4.4 }, { "text": "rand int it's a bit hard to say but it", "start": 659.76, "duration": 4.639 }, { "text": "implies get back a random int and if you", "start": 662.16, "duration": 4.16 }, { "text": "read the documentation it's a random end", "start": 664.399, "duration": 4.161 }, { "text": "that's between a and b", "start": 666.32, "duration": 4.72 }, { "text": "inclusive so if you were to pass in 1", "start": 668.56, "duration": 5.04 }, { "text": "for a and 10 for b you would get back a", "start": 671.04, "duration": 4.88 }, { "text": "number between 1 and 10 inclusive", "start": 673.6, "duration": 4.32 }, { "text": "including the 1 and including the 10", "start": 675.92, "duration": 4.88 }, { "text": "potentially each with a 10 probability", "start": 677.92, "duration": 4.8 }, { "text": "so how might i go about using a program", "start": 680.8, "duration": 3.52 }, { "text": "like this well let me come back to my", "start": 682.72, "duration": 4.0 }, { "text": "generate.pi file and why don't we go", "start": 684.32, "duration": 4.32 }, { "text": "ahead and try generating a random number", "start": 686.72, "duration": 3.28 }, { "text": "between one and ten you might do this", "start": 688.64, "duration": 2.639 }, { "text": "frequently in the real world when you", "start": 690.0, "duration": 2.399 }, { "text": "just want someone to pick a random", "start": 691.279, "duration": 2.321 }, { "text": "number you tell them as much and the", "start": 692.399, "duration": 3.281 }, { "text": "human responds let's get the computer to", "start": 693.6, "duration": 3.919 }, { "text": "do the same here let me go ahead and", "start": 695.68, "duration": 3.599 }, { "text": "delete my two lines of code at the", "start": 697.519, "duration": 3.841 }, { "text": "bottom but keep my import random and", "start": 699.279, "duration": 3.521 }, { "text": "let's go ahead and define a variable", "start": 701.36, "duration": 3.52 }, { "text": "this time called number set it equal to", "start": 702.8, "duration": 4.96 }, { "text": "the return value of random.randint", "start": 704.88, "duration": 4.639 }, { "text": "and now pass in a", "start": 707.76, "duration": 5.44 }, { "text": "a value of 1 and b a value of 10 and now", "start": 709.519, "duration": 6.081 }, { "text": "let's go ahead and print the number i'm", "start": 713.2, "duration": 3.92 }, { "text": "going to go ahead in my terminal window", "start": 715.6, "duration": 3.6 }, { "text": "and run python of generate dot pi and", "start": 717.12, "duration": 3.279 }, { "text": "hit enter", "start": 719.2, "duration": 2.72 }, { "text": "four", "start": 720.399, "duration": 4.0 }, { "text": "python of generate.pi and hit enter", "start": 721.92, "duration": 4.159 }, { "text": "eight again", "start": 724.399, "duration": 6.081 }, { "text": "nine again seven again ten again", "start": 726.079, "duration": 6.401 }, { "text": "two again and we can do this all day", "start": 730.48, "duration": 3.76 }, { "text": "long and if we add all those up they", "start": 732.48, "duration": 3.76 }, { "text": "should end up being with ten percent", "start": 734.24, "duration": 4.56 }, { "text": "probability each now how might you use", "start": 736.24, "duration": 3.839 }, { "text": "this information well maybe we're", "start": 738.8, "duration": 2.8 }, { "text": "playing a guessing game or maybe we're", "start": 740.079, "duration": 4.241 }, { "text": "trying to randomize the behavior of some", "start": 741.6, "duration": 4.799 }, { "text": "character in the game you can imagine", "start": 744.32, "duration": 4.079 }, { "text": "using very simple building blocks like", "start": 746.399, "duration": 3.761 }, { "text": "this just kind of spicing up your", "start": 748.399, "duration": 3.44 }, { "text": "program by getting it to do things a", "start": 750.16, "duration": 4.0 }, { "text": "little less predictably because you're", "start": 751.839, "duration": 4.641 }, { "text": "choosing these values seemingly randomly", "start": 754.16, "duration": 3.6 }, { "text": "and you're deferring to python to", "start": 756.48, "duration": 3.039 }, { "text": "actually do the generation of these", "start": 757.76, "duration": 2.8 }, { "text": "numbers", "start": 759.519, "duration": 3.041 }, { "text": "using its own algorithms and its own", "start": 760.56, "duration": 4.079 }, { "text": "math well what more could we do here let", "start": 762.56, "duration": 3.6 }, { "text": "me propose that we introduce another", "start": 764.639, "duration": 2.961 }, { "text": "function that comes from this random", "start": 766.16, "duration": 3.04 }, { "text": "library yet another that you yourself", "start": 767.6, "duration": 4.239 }, { "text": "have to don't have to implement shuffle", "start": 769.2, "duration": 4.079 }, { "text": "if you read the documentation for", "start": 771.839, "duration": 3.761 }, { "text": "shuffle in the same random module you'll", "start": 773.279, "duration": 4.321 }, { "text": "see that it takes in a list for instance", "start": 775.6, "duration": 4.32 }, { "text": "of values and just shuffles them up it", "start": 777.6, "duration": 4.799 }, { "text": "randomizes them like a deck of cards", "start": 779.92, "duration": 4.0 }, { "text": "here you might shuffle them so it's to", "start": 782.399, "duration": 3.521 }, { "text": "put them into seemingly random order", "start": 783.92, "duration": 4.24 }, { "text": "well how do i use this based on this", "start": 785.92, "duration": 4.08 }, { "text": "function's name well let me propose that", "start": 788.16, "duration": 4.16 }, { "text": "we go back to vs code here and let me go", "start": 790.0, "duration": 4.56 }, { "text": "ahead and this time do the following", "start": 792.32, "duration": 4.16 }, { "text": "because i need to shuffle something like", "start": 794.56, "duration": 3.76 }, { "text": "a deck of cards let me go ahead and not", "start": 796.48, "duration": 3.44 }, { "text": "just import random but let me give", "start": 798.32, "duration": 3.68 }, { "text": "myself a variable called cards that's", "start": 799.92, "duration": 4.159 }, { "text": "going to be of type list and just so i", "start": 802.0, "duration": 3.839 }, { "text": "have something to shuffle i don't need", "start": 804.079, "duration": 4.161 }, { "text": "all 52 cards in a typical deck i'm just", "start": 805.839, "duration": 4.721 }, { "text": "going to shuffle three cards a jack a", "start": 808.24, "duration": 4.48 }, { "text": "queen and a king i could call those", "start": 810.56, "duration": 3.519 }, { "text": "strings anything i want but i just", "start": 812.72, "duration": 3.6 }, { "text": "wanted a list of some values so as to", "start": 814.079, "duration": 4.081 }, { "text": "shuffle them up that is randomize the", "start": 816.32, "duration": 3.92 }, { "text": "order they're in well how does this now", "start": 818.16, "duration": 3.679 }, { "text": "work if you read the documentation for", "start": 820.24, "duration": 4.08 }, { "text": "random.shuffle you'll see that it", "start": 821.839, "duration": 5.841 }, { "text": "shuffles the argument in place that is", "start": 824.32, "duration": 5.04 }, { "text": "unlike many of the functions we've seen", "start": 827.68, "duration": 4.08 }, { "text": "it doesn't return to a value that", "start": 829.36, "duration": 4.719 }, { "text": "contains the shuffled cards in this case", "start": 831.76, "duration": 5.04 }, { "text": "it actually shuffles the list it's given", "start": 834.079, "duration": 4.88 }, { "text": "itself so what this means for my code is", "start": 836.8, "duration": 4.08 }, { "text": "that i need to do something like this", "start": 838.959, "duration": 5.041 }, { "text": "random random.shuffle and pass in the", "start": 840.88, "duration": 6.0 }, { "text": "variable containing those cards and then", "start": 844.0, "duration": 5.12 }, { "text": "on a final line here how might i go", "start": 846.88, "duration": 4.88 }, { "text": "about printing the cards well i could do", "start": 849.12, "duration": 5.12 }, { "text": "this and i could say print cards but if", "start": 851.76, "duration": 3.84 }, { "text": "i do that i'm actually going to see", "start": 854.24, "duration": 3.44 }, { "text": "python syntax for lists and it's just", "start": 855.6, "duration": 4.32 }, { "text": "going to format in its own way using", "start": 857.68, "duration": 3.76 }, { "text": "commas and the like i want to print", "start": 859.92, "duration": 3.12 }, { "text": "these cards out one at a time just", "start": 861.44, "duration": 2.8 }, { "text": "because i think it'll look a little", "start": 863.04, "duration": 3.28 }, { "text": "better so we can use some of our syntax", "start": 864.24, "duration": 4.48 }, { "text": "from loops and say something like this", "start": 866.32, "duration": 5.84 }, { "text": "for card in cards go ahead and print out", "start": 868.72, "duration": 5.919 }, { "text": "the current card so what's now happening", "start": 872.16, "duration": 4.96 }, { "text": "here line three i'm defining a list of", "start": 874.639, "duration": 5.76 }, { "text": "three cards in this order jack queen", "start": 877.12, "duration": 4.079 }, { "text": "king", "start": 880.399, "duration": 2.56 }, { "text": "i'm then shuffling those same cards on", "start": 881.199, "duration": 3.841 }, { "text": "line four and then on line five i'm", "start": 882.959, "duration": 4.721 }, { "text": "using a for loop for each of the cards", "start": 885.04, "duration": 5.599 }, { "text": "in that list print it out one at a time", "start": 887.68, "duration": 5.36 }, { "text": "and because i'm using print one line at", "start": 890.639, "duration": 4.32 }, { "text": "a time well let's see the results down", "start": 893.04, "duration": 3.039 }, { "text": "here in my terminal window i'm going to", "start": 894.959, "duration": 3.761 }, { "text": "run python of generate.pi and hit enter", "start": 896.079, "duration": 5.44 }, { "text": "queen king jack seemingly shuffled", "start": 898.72, "duration": 4.559 }, { "text": "because that's not the order i defined", "start": 901.519, "duration": 3.921 }, { "text": "earlier let's do it again", "start": 903.279, "duration": 4.321 }, { "text": "queen king jack", "start": 905.44, "duration": 3.839 }, { "text": "okay that happens to be the same but", "start": 907.6, "duration": 4.08 }, { "text": "let's see this could just be bad chance", "start": 909.279, "duration": 5.281 }, { "text": "there we go jack queen king doesn't look", "start": 911.68, "duration": 4.399 }, { "text": "like it's shuffled but at least we're", "start": 914.56, "duration": 3.279 }, { "text": "getting back different orderings now", "start": 916.079, "duration": 2.721 }, { "text": "again", "start": 917.839, "duration": 3.921 }, { "text": "jack queen king not so good", "start": 918.8, "duration": 4.88 }, { "text": "jack queen king not so good this is", "start": 921.76, "duration": 2.879 }, { "text": "someone you probably want to play", "start": 923.68, "duration": 3.519 }, { "text": "against with cards queen jack king there", "start": 924.639, "duration": 4.56 }, { "text": "we go but of course we only have three", "start": 927.199, "duration": 4.0 }, { "text": "cards here so there's not that many", "start": 929.199, "duration": 3.601 }, { "text": "permutations we might see and if we do", "start": 931.199, "duration": 3.601 }, { "text": "this over time we will see all of them", "start": 932.8, "duration": 4.64 }, { "text": "but if we had of course 13 or 52 cards", "start": 934.8, "duration": 5.2 }, { "text": "we'd see a lot more permutations instead", "start": 937.44, "duration": 4.48 }, { "text": "so we have now these three ways to", "start": 940.0, "duration": 3.6 }, { "text": "generate random information one is", "start": 941.92, "duration": 3.68 }, { "text": "simple coin toss if you want to start", "start": 943.6, "duration": 4.0 }, { "text": "some kind of athletic event one pick a", "start": 945.6, "duration": 3.599 }, { "text": "number between 1 and 10 if you want to", "start": 947.6, "duration": 3.359 }, { "text": "decide something based on that and now", "start": 949.199, "duration": 4.0 }, { "text": "using shuffle we can even take in a list", "start": 950.959, "duration": 4.401 }, { "text": "of things and shuffle them about so that", "start": 953.199, "duration": 5.121 }, { "text": "we get some kind of random behavior but", "start": 955.36, "duration": 4.719 }, { "text": "let me pause here and see if there's any", "start": 958.32, "duration": 2.959 }, { "text": "questions yet", "start": 960.079, "duration": 4.88 }, { "text": "on random on modules or any of these", "start": 961.279, "duration": 5.521 }, { "text": "three functions", "start": 964.959, "duration": 4.32 }, { "text": "yeah uh can we increase or decrease the", "start": 966.8, "duration": 4.399 }, { "text": "probability", "start": 969.279, "duration": 3.92 }, { "text": "of cards", "start": 971.199, "duration": 4.401 }, { "text": "if you want to uh for example there is", "start": 973.199, "duration": 4.401 }, { "text": "three there is a 33 percent chance of", "start": 975.6, "duration": 3.28 }, { "text": "probability", "start": 977.6, "duration": 3.359 }, { "text": "so is there any chance to increase or", "start": 978.88, "duration": 4.16 }, { "text": "decrease the probability can you set", "start": 980.959, "duration": 4.401 }, { "text": "these probabilities not using these same", "start": 983.04, "duration": 4.08 }, { "text": "functions uh can you set the", "start": 985.36, "duration": 4.0 }, { "text": "probabilities but you can absolutely", "start": 987.12, "duration": 3.92 }, { "text": "implement some of your own functions or", "start": 989.36, "duration": 3.44 }, { "text": "use more sophisticated functions that do", "start": 991.04, "duration": 3.68 }, { "text": "exist in this library and others to", "start": 992.8, "duration": 3.92 }, { "text": "exercise more control these are meant to", "start": 994.72, "duration": 3.6 }, { "text": "be very user-friendly and simple", "start": 996.72, "duration": 2.96 }, { "text": "functions certainly the ones we looked", "start": 998.32, "duration": 3.199 }, { "text": "at that give you equal probability for", "start": 999.68, "duration": 3.76 }, { "text": "all of those but absolutely you could", "start": 1001.519, "duration": 3.76 }, { "text": "skew things though hopefully if you're", "start": 1003.44, "duration": 3.36 }, { "text": "implementing a gambling game or the like", "start": 1005.279, "duration": 3.12 }, { "text": "you're not actually making some cards", "start": 1006.8, "duration": 3.92 }, { "text": "more probable than others", "start": 1008.399, "duration": 4.481 }, { "text": "allow me to turn back now to our", "start": 1010.72, "duration": 4.16 }, { "text": "implementation here of this randomness", "start": 1012.88, "duration": 3.92 }, { "text": "and consider how we might leverage other", "start": 1014.88, "duration": 3.44 }, { "text": "types of functionality that aren't", "start": 1016.8, "duration": 3.76 }, { "text": "necessarily in this specific library", "start": 1018.32, "duration": 4.4 }, { "text": "here well it turns out that python also", "start": 1020.56, "duration": 4.239 }, { "text": "comes with a statistics library and this", "start": 1022.72, "duration": 3.68 }, { "text": "contains all sorts of functions for", "start": 1024.799, "duration": 3.921 }, { "text": "doing things more statistical in nature", "start": 1026.4, "duration": 4.96 }, { "text": "namely calculating means or medians or", "start": 1028.72, "duration": 4.479 }, { "text": "modes or other", "start": 1031.36, "duration": 3.599 }, { "text": "aspects of a data set that you might", "start": 1033.199, "duration": 4.24 }, { "text": "want to analyze so how might we use the", "start": 1034.959, "duration": 4.321 }, { "text": "statistics module on python well we", "start": 1037.439, "duration": 2.961 }, { "text": "might first just take a look at its", "start": 1039.28, "duration": 3.36 }, { "text": "documentation like any other module in", "start": 1040.4, "duration": 4.08 }, { "text": "python and we'll see within that library", "start": 1042.64, "duration": 3.52 }, { "text": "that there's a whole bunch of functions", "start": 1044.48, "duration": 3.359 }, { "text": "and one of those functions is one that's", "start": 1046.16, "duration": 3.68 }, { "text": "quite simple it's average a function", "start": 1047.839, "duration": 4.08 }, { "text": "that allows you to calculate the average", "start": 1049.84, "duration": 4.16 }, { "text": "of some numbers that you've passed in", "start": 1051.919, "duration": 3.76 }, { "text": "let me go ahead and envious code in my", "start": 1054.0, "duration": 3.84 }, { "text": "terminal window open up a new file", "start": 1055.679, "duration": 4.721 }, { "text": "called average.pi and at the top of this", "start": 1057.84, "duration": 4.32 }, { "text": "file i'm going to import a different", "start": 1060.4, "duration": 4.24 }, { "text": "library this time namely the statistics", "start": 1062.16, "duration": 4.8 }, { "text": "module in python and now i'm going to go", "start": 1064.64, "duration": 4.08 }, { "text": "ahead and call a function that i know", "start": 1066.96, "duration": 4.88 }, { "text": "comes in that module namely mean for the", "start": 1068.72, "duration": 4.64 }, { "text": "average of some values and i'm going to", "start": 1071.84, "duration": 3.68 }, { "text": "call statistics.mean", "start": 1073.36, "duration": 4.96 }, { "text": "and i'm going to pass into this function", "start": 1075.52, "duration": 4.72 }, { "text": "mean a list of some values and let's", "start": 1078.32, "duration": 3.28 }, { "text": "suppose that i'm quickly trying to", "start": 1080.24, "duration": 3.6 }, { "text": "calculate what my current grade average", "start": 1081.6, "duration": 4.24 }, { "text": "is in school and i did really well on my", "start": 1083.84, "duration": 3.839 }, { "text": "first test and i got a hundred percent", "start": 1085.84, "duration": 3.68 }, { "text": "and on my second i did well but not as", "start": 1087.679, "duration": 4.161 }, { "text": "well and i got a 90. and ironically i'm", "start": 1089.52, "duration": 3.84 }, { "text": "not very good with math so i'd like to", "start": 1091.84, "duration": 3.28 }, { "text": "figure out what my average now is", "start": 1093.36, "duration": 3.439 }, { "text": "between those two tests so let me go", "start": 1095.12, "duration": 3.6 }, { "text": "ahead now and in this list type in the", "start": 1096.799, "duration": 5.201 }, { "text": "number 100 comma 90 thereby passing in a", "start": 1098.72, "duration": 6.88 }, { "text": "list of two values two ants 190 and ins", "start": 1102.0, "duration": 5.2 }, { "text": "outside of those are the parentheses", "start": 1105.6, "duration": 3.04 }, { "text": "because of course this is now the", "start": 1107.2, "duration": 3.04 }, { "text": "argument i'm passing to the function", "start": 1108.64, "duration": 4.24 }, { "text": "called mean and this function mean is in", "start": 1110.24, "duration": 5.439 }, { "text": "the module called statistics well it's", "start": 1112.88, "duration": 4.48 }, { "text": "not that interesting to just calculate", "start": 1115.679, "duration": 3.36 }, { "text": "the mean if i don't actually see what it", "start": 1117.36, "duration": 3.52 }, { "text": "is so let me additionally pass the", "start": 1119.039, "duration": 4.241 }, { "text": "return value of that mean function to", "start": 1120.88, "duration": 4.72 }, { "text": "the print function as usual let me now", "start": 1123.28, "duration": 4.48 }, { "text": "in my terminal window in vs code type in", "start": 1125.6, "duration": 4.56 }, { "text": "python of average.pi and hit enter and", "start": 1127.76, "duration": 4.96 }, { "text": "voila as you might expect my average is", "start": 1130.16, "duration": 3.759 }, { "text": "95", "start": 1132.72, "duration": 2.56 }, { "text": "so the difference here is that i'm just", "start": 1133.919, "duration": 2.961 }, { "text": "using a different module that still", "start": 1135.28, "duration": 3.519 }, { "text": "comes with python but i need to import", "start": 1136.88, "duration": 4.32 }, { "text": "it instead of for instance the random", "start": 1138.799, "duration": 4.321 }, { "text": "module instead and this time i know from", "start": 1141.2, "duration": 3.44 }, { "text": "the documentation that there exists a", "start": 1143.12, "duration": 4.16 }, { "text": "function called mean well it turns out", "start": 1144.64, "duration": 4.72 }, { "text": "there's even more functionality that", "start": 1147.28, "duration": 4.08 }, { "text": "comes with python and that comes with", "start": 1149.36, "duration": 2.8 }, { "text": "other", "start": 1151.36, "duration": 2.48 }, { "text": "modules in python and there's this", "start": 1152.16, "duration": 3.6 }, { "text": "feature generally known as command line", "start": 1153.84, "duration": 3.68 }, { "text": "arguments this is a feature not just of", "start": 1155.76, "duration": 4.0 }, { "text": "python but of languages more generally", "start": 1157.52, "duration": 4.88 }, { "text": "that allow you to provide input not when", "start": 1159.76, "duration": 5.44 }, { "text": "prompted inside of a program as happens", "start": 1162.4, "duration": 5.279 }, { "text": "whenever we call the python function", "start": 1165.2, "duration": 4.96 }, { "text": "input but rather there's this feature", "start": 1167.679, "duration": 4.321 }, { "text": "command line arguments of programs that", "start": 1170.16, "duration": 4.0 }, { "text": "allows you to provide arguments that is", "start": 1172.0, "duration": 4.08 }, { "text": "input to the program", "start": 1174.16, "duration": 3.519 }, { "text": "just when you're executing it at the", "start": 1176.08, "duration": 3.28 }, { "text": "command line so up until now for", "start": 1177.679, "duration": 3.36 }, { "text": "instance recall that we've generally run", "start": 1179.36, "duration": 3.84 }, { "text": "python of something dot pi for instance", "start": 1181.039, "duration": 4.961 }, { "text": "python of hello dot pi and i've never", "start": 1183.2, "duration": 5.2 }, { "text": "once really executed any words or", "start": 1186.0, "duration": 5.52 }, { "text": "phrases after the name of the file but i", "start": 1188.4, "duration": 5.68 }, { "text": "could in fact when you're running", "start": 1191.52, "duration": 4.8 }, { "text": "programs in a command like environment", "start": 1194.08, "duration": 4.4 }, { "text": "like we are you can provide any number", "start": 1196.32, "duration": 5.52 }, { "text": "of words or numbers or phrases after the", "start": 1198.48, "duration": 4.88 }, { "text": "command that you're typing and all of", "start": 1201.84, "duration": 3.6 }, { "text": "those will somehow be passed in as", "start": 1203.36, "duration": 4.64 }, { "text": "inputs to the program itself you don't", "start": 1205.44, "duration": 5.599 }, { "text": "have to prompt the user for one thing at", "start": 1208.0, "duration": 5.28 }, { "text": "a time by manually calling that input", "start": 1211.039, "duration": 4.161 }, { "text": "function so what does this mean in real", "start": 1213.28, "duration": 4.08 }, { "text": "terms well let me go ahead back into vs", "start": 1215.2, "duration": 5.04 }, { "text": "code here and let me propose that we", "start": 1217.36, "duration": 5.76 }, { "text": "consider how we might leverage a certain", "start": 1220.24, "duration": 4.64 }, { "text": "module i'm going to go ahead and create", "start": 1223.12, "duration": 3.28 }, { "text": "a file called", "start": 1224.88, "duration": 4.64 }, { "text": "name.pi and i'd like to use a new module", "start": 1226.4, "duration": 5.12 }, { "text": "this time that's going to give me access", "start": 1229.52, "duration": 3.76 }, { "text": "to", "start": 1231.52, "duration": 3.039 }, { "text": "values that have been typed at that", "start": 1233.28, "duration": 3.12 }, { "text": "command line but what's this module", "start": 1234.559, "duration": 3.36 }, { "text": "going to be well this one's going to be", "start": 1236.4, "duration": 4.159 }, { "text": "called sys and sys short for system", "start": 1237.919, "duration": 4.24 }, { "text": "contains a whole lot of functionality", "start": 1240.559, "duration": 4.081 }, { "text": "that's specific to the system itself and", "start": 1242.159, "duration": 4.321 }, { "text": "the commands that you and i are typing", "start": 1244.64, "duration": 3.76 }, { "text": "the documentation for this module is at", "start": 1246.48, "duration": 4.16 }, { "text": "this url here and it lists all of the", "start": 1248.4, "duration": 4.159 }, { "text": "various functions and variables and the", "start": 1250.64, "duration": 4.159 }, { "text": "like that come with that module but", "start": 1252.559, "duration": 3.521 }, { "text": "we're going to focus on something a", "start": 1254.799, "duration": 3.521 }, { "text": "little more specific namely this thing", "start": 1256.08, "duration": 4.76 }, { "text": "here it turns out in the sys module in", "start": 1258.32, "duration": 5.2 }, { "text": "python there is a variable that just", "start": 1260.84, "duration": 6.04 }, { "text": "magically exists for you called argv it", "start": 1263.52, "duration": 5.44 }, { "text": "stands for argument vector which is a", "start": 1266.88, "duration": 4.56 }, { "text": "fancy way of describing the list of all", "start": 1268.96, "duration": 4.64 }, { "text": "of the words that the human typed in at", "start": 1271.44, "duration": 3.52 }, { "text": "their prompt", "start": 1273.6, "duration": 3.84 }, { "text": "before they hit enter all of those are", "start": 1274.96, "duration": 5.44 }, { "text": "seemingly magically provided to you via", "start": 1277.44, "duration": 6.64 }, { "text": "python in a variable called sys.rgv", "start": 1280.4, "duration": 6.32 }, { "text": "this variable is a list which means that", "start": 1284.08, "duration": 4.0 }, { "text": "the first element is going to be the", "start": 1286.72, "duration": 2.72 }, { "text": "first word that you type the second", "start": 1288.08, "duration": 2.479 }, { "text": "element is going to be the second word", "start": 1289.44, "duration": 3.119 }, { "text": "that you typed and so forth and by way", "start": 1290.559, "duration": 4.081 }, { "text": "of this list then can you figure out", "start": 1292.559, "duration": 3.841 }, { "text": "what words did the human actually type", "start": 1294.64, "duration": 3.519 }, { "text": "at the prompt and maybe use that to", "start": 1296.4, "duration": 4.08 }, { "text": "influence the behavior of your own", "start": 1298.159, "duration": 4.081 }, { "text": "program so what does this mean now in", "start": 1300.48, "duration": 3.6 }, { "text": "real terms well in this new tab called", "start": 1302.24, "duration": 4.64 }, { "text": "name dot pi let me go ahead and import", "start": 1304.08, "duration": 5.52 }, { "text": "sys within that sys module is going to", "start": 1306.88, "duration": 5.52 }, { "text": "give me access to sys.rgv but how might", "start": 1309.6, "duration": 4.8 }, { "text": "i want to use it well let's do this", "start": 1312.4, "duration": 4.24 }, { "text": "instead of writing a hello world program", "start": 1314.4, "duration": 5.36 }, { "text": "that all of these times has just looked", "start": 1316.64, "duration": 5.519 }, { "text": "for the return value of input to figure", "start": 1319.76, "duration": 4.64 }, { "text": "out what the user wants me to print", "start": 1322.159, "duration": 3.921 }, { "text": "let's go ahead and just expect the user", "start": 1324.4, "duration": 3.44 }, { "text": "to tell us when they run the python", "start": 1326.08, "duration": 4.0 }, { "text": "program itself what their name is and", "start": 1327.84, "duration": 3.76 }, { "text": "suppose this time i'd like to generate a", "start": 1330.08, "duration": 3.76 }, { "text": "whole bunch of name tags initially just", "start": 1331.6, "duration": 4.319 }, { "text": "one and in the us here it's very common", "start": 1333.84, "duration": 3.6 }, { "text": "to wear a sticker on your lapel that", "start": 1335.919, "duration": 3.76 }, { "text": "says hello my name is david so i want to", "start": 1337.44, "duration": 4.0 }, { "text": "print out some text that resembles that", "start": 1339.679, "duration": 3.521 }, { "text": "the idea being maybe i could enhance", "start": 1341.44, "duration": 3.599 }, { "text": "this program someday to even send that", "start": 1343.2, "duration": 3.2 }, { "text": "text straight to the printer and", "start": 1345.039, "duration": 3.681 }, { "text": "dynamically generate those name tags", "start": 1346.4, "duration": 4.0 }, { "text": "well let me go ahead now and do this let", "start": 1348.72, "duration": 3.52 }, { "text": "me go ahead and print out as always", "start": 1350.4, "duration": 3.44 }, { "text": "hello but i'll say a little something", "start": 1352.24, "duration": 2.88 }, { "text": "more this time to make things more", "start": 1353.84, "duration": 3.839 }, { "text": "interesting hello my name is quote", "start": 1355.12, "duration": 5.919 }, { "text": "unquote and then after that i normally", "start": 1357.679, "duration": 5.761 }, { "text": "have been in the habit of calling input", "start": 1361.039, "duration": 4.561 }, { "text": "storing the return value in a variable", "start": 1363.44, "duration": 4.479 }, { "text": "and passing in the name of that variable", "start": 1365.6, "duration": 4.24 }, { "text": "here but i'm going to instead jump right", "start": 1367.919, "duration": 3.161 }, { "text": "to this", "start": 1369.84, "duration": 5.28 }, { "text": "sys.rv bracket one and that's it", "start": 1371.08, "duration": 5.56 }, { "text": "i'm going to have a program here that", "start": 1375.12, "duration": 3.76 }, { "text": "says hello my name is followed by", "start": 1376.64, "duration": 6.0 }, { "text": "whatever is in sys.rv bracket one and", "start": 1378.88, "duration": 6.0 }, { "text": "notice sis.rgv again is a list and", "start": 1382.64, "duration": 4.08 }, { "text": "recall from our discussion of loops and", "start": 1384.88, "duration": 3.84 }, { "text": "in turn list we use the square bracket", "start": 1386.72, "duration": 4.88 }, { "text": "notation to get at the various elements", "start": 1388.72, "duration": 4.64 }, { "text": "inside of a list all right let me go", "start": 1391.6, "duration": 3.84 }, { "text": "down now into my terminal window and run", "start": 1393.36, "duration": 4.48 }, { "text": "python of name dot pi but this time", "start": 1395.44, "duration": 4.4 }, { "text": "rather than just hit enter and wait for", "start": 1397.84, "duration": 3.76 }, { "text": "the program to prompt me for my name let", "start": 1399.84, "duration": 3.92 }, { "text": "me proactively just tell this program", "start": 1401.6, "duration": 4.319 }, { "text": "what my name is at the so-called command", "start": 1403.76, "duration": 5.039 }, { "text": "line here we go dav id separated with a", "start": 1405.919, "duration": 5.281 }, { "text": "space from the name of the file so that", "start": 1408.799, "duration": 4.961 }, { "text": "now when i execute python name dot pi", "start": 1411.2, "duration": 6.16 }, { "text": "david i see on the screen voila hello my", "start": 1413.76, "duration": 5.919 }, { "text": "name is david so based on this", "start": 1417.36, "duration": 4.559 }, { "text": "demonstration alone i think we can infer", "start": 1419.679, "duration": 4.48 }, { "text": "exactly what's going on in sys.rg even", "start": 1421.919, "duration": 4.0 }, { "text": "though it sounds certainly at first", "start": 1424.159, "duration": 2.801 }, { "text": "glance", "start": 1425.919, "duration": 3.401 }, { "text": "rather complicated here let's look up at", "start": 1426.96, "duration": 6.64 }, { "text": "sys.rgv i'm going to bracket one here so", "start": 1429.32, "duration": 8.2 }, { "text": "clearly sys.rv bracket one", "start": 1433.6, "duration": 7.92 }, { "text": "is storing dav id but it's one in the", "start": 1437.52, "duration": 6.08 }, { "text": "past when we looked at loops recall that", "start": 1441.52, "duration": 4.48 }, { "text": "we said that they were zero indexed that", "start": 1443.6, "duration": 4.48 }, { "text": "is the first element is zero the next", "start": 1446.0, "duration": 4.799 }, { "text": "element is one this next element is two", "start": 1448.08, "duration": 5.28 }, { "text": "and so forth and yet here i am treating", "start": 1450.799, "duration": 4.24 }, { "text": "it as though my name is at the start of", "start": 1453.36, "duration": 4.24 }, { "text": "the list one well let me ask this", "start": 1455.039, "duration": 3.681 }, { "text": "question", "start": 1457.6, "duration": 5.439 }, { "text": "what is probably in cis.rgv of zero", "start": 1458.72, "duration": 8.8 }, { "text": "what is probably insist dot argv of zero", "start": 1463.039, "duration": 7.12 }, { "text": "the very first element actually in that", "start": 1467.52, "duration": 5.759 }, { "text": "list oh yeah i think", "start": 1470.159, "duration": 5.361 }, { "text": "it's like in c", "start": 1473.279, "duration": 4.321 }, { "text": "the name of program", "start": 1475.52, "duration": 4.08 }, { "text": "indeed it's indeed like in c in other", "start": 1477.6, "duration": 4.319 }, { "text": "languages the name of the program well", "start": 1479.6, "duration": 4.72 }, { "text": "if we consider what it was i typed i", "start": 1481.919, "duration": 3.921 }, { "text": "certainly typed python because that's", "start": 1484.32, "duration": 3.12 }, { "text": "the name of my interpreter and we don't", "start": 1485.84, "duration": 3.12 }, { "text": "really need to know that because we're", "start": 1487.44, "duration": 3.76 }, { "text": "using python itself but after that i did", "start": 1488.96, "duration": 4.719 }, { "text": "type two things i typed name dot pi as", "start": 1491.2, "duration": 4.4 }, { "text": "i've done so many times anytime i want", "start": 1493.679, "duration": 3.681 }, { "text": "python to interpret a program i've", "start": 1495.6, "duration": 3.679 }, { "text": "written and it turns out by convention", "start": 1497.36, "duration": 5.04 }, { "text": "what python does is it stores in sys.rgv", "start": 1499.279, "duration": 5.361 }, { "text": "the name of the file that you're", "start": 1502.4, "duration": 5.12 }, { "text": "executing or interpreting followed by", "start": 1504.64, "duration": 5.2 }, { "text": "any number of other words that you typed", "start": 1507.52, "duration": 4.399 }, { "text": "so all this time we could have been", "start": 1509.84, "duration": 3.68 }, { "text": "accessing the name of the program which", "start": 1511.919, "duration": 3.36 }, { "text": "frankly isn't all that interesting but", "start": 1513.52, "duration": 4.0 }, { "text": "we can also now access words that are", "start": 1515.279, "duration": 5.041 }, { "text": "typed after that prompt as well", "start": 1517.52, "duration": 5.6 }, { "text": "but of course if i don't type anything", "start": 1520.32, "duration": 3.839 }, { "text": "in", "start": 1523.12, "duration": 2.799 }, { "text": "what might happen here this might be", "start": 1524.159, "duration": 3.201 }, { "text": "naive of me to assume that there's", "start": 1525.919, "duration": 3.12 }, { "text": "always going to be something at location", "start": 1527.36, "duration": 4.24 }, { "text": "1 in sys.rgv let me go ahead and try", "start": 1529.039, "duration": 5.52 }, { "text": "this python name dot pi and no i'm not", "start": 1531.6, "duration": 4.64 }, { "text": "giving you my name because at this point", "start": 1534.559, "duration": 3.681 }, { "text": "i might not even know that you want my", "start": 1536.24, "duration": 4.4 }, { "text": "name to be typed so let me hit enter now", "start": 1538.24, "duration": 4.72 }, { "text": "and uh uh-oh we see now an error a", "start": 1540.64, "duration": 4.56 }, { "text": "so-called exception in python this one's", "start": 1542.96, "duration": 5.04 }, { "text": "a new one this one's an index error that", "start": 1545.2, "duration": 5.92 }, { "text": "elaborates list index out of range and", "start": 1548.0, "duration": 4.4 }, { "text": "turns out this is actually one of the", "start": 1551.12, "duration": 3.36 }, { "text": "most common mistakes in programming", "start": 1552.4, "duration": 4.8 }, { "text": "whether using a list in python or arrays", "start": 1554.48, "duration": 4.88 }, { "text": "or vectors in other languages is to try", "start": 1557.2, "duration": 4.32 }, { "text": "to access some element that does not", "start": 1559.36, "duration": 4.319 }, { "text": "exist you try to go too far to the left", "start": 1561.52, "duration": 4.159 }, { "text": "or you try to go too far to the right in", "start": 1563.679, "duration": 3.201 }, { "text": "this", "start": 1565.679, "duration": 3.6 }, { "text": "in this object that is just a list of", "start": 1566.88, "duration": 4.96 }, { "text": "some values so of course the mistake", "start": 1569.279, "duration": 4.321 }, { "text": "here is that i'm assuming there's going", "start": 1571.84, "duration": 3.839 }, { "text": "to be something at location one when", "start": 1573.6, "duration": 4.4 }, { "text": "really it's location zero that's the", "start": 1575.679, "duration": 4.401 }, { "text": "only one that has a value but fixing", "start": 1578.0, "duration": 4.159 }, { "text": "this is not going to amount to doing", "start": 1580.08, "duration": 4.32 }, { "text": "bracket zero because now if i go ahead", "start": 1582.159, "duration": 4.4 }, { "text": "and rerun this program with no other", "start": 1584.4, "duration": 4.8 }, { "text": "words after name.pi it says hello my", "start": 1586.559, "duration": 4.961 }, { "text": "name is name.pie which is fine if we're", "start": 1589.2, "duration": 4.0 }, { "text": "making a name tag for the program but", "start": 1591.52, "duration": 3.68 }, { "text": "that's not of course what my goal here", "start": 1593.2, "duration": 4.64 }, { "text": "is instead so if the fix is not just to", "start": 1595.2, "duration": 4.8 }, { "text": "change the one to a zero", "start": 1597.84, "duration": 5.68 }, { "text": "how else might i handle this error", "start": 1600.0, "duration": 6.08 }, { "text": "how else might i handle this error", "start": 1603.52, "duration": 4.399 }, { "text": "this index error that happens if the", "start": 1606.08, "duration": 4.0 }, { "text": "user just doesn't remember to or doesn't", "start": 1607.919, "duration": 4.321 }, { "text": "know to type their actual name at the", "start": 1610.08, "duration": 3.44 }, { "text": "prompt", "start": 1612.24, "duration": 3.36 }, { "text": "we could always put an exception into", "start": 1613.52, "duration": 4.0 }, { "text": "the program saying", "start": 1615.6, "duration": 4.959 }, { "text": "if there is um if there's nothing at", "start": 1617.52, "duration": 4.72 }, { "text": "location one", "start": 1620.559, "duration": 4.0 }, { "text": "we just come out to say okay we haven't", "start": 1622.24, "duration": 4.4 }, { "text": "got a parameter or something but if", "start": 1624.559, "duration": 3.921 }, { "text": "there is you continue along with the", "start": 1626.64, "duration": 3.12 }, { "text": "program", "start": 1628.48, "duration": 3.28 }, { "text": "perfect so if i might simplify we can", "start": 1629.76, "duration": 4.24 }, { "text": "try to execute this line of code except", "start": 1631.76, "duration": 3.6 }, { "text": "if there's an error we'll deal with it", "start": 1634.0, "duration": 3.919 }, { "text": "in some other way now ideally and once", "start": 1635.36, "duration": 4.24 }, { "text": "i'm a strong enough programmer i would", "start": 1637.919, "duration": 3.601 }, { "text": "have anticipated this and written the", "start": 1639.6, "duration": 4.0 }, { "text": "following code from the get-go but when", "start": 1641.52, "duration": 3.039 }, { "text": "you're learning it's certainly", "start": 1643.6, "duration": 2.559 }, { "text": "reasonable to see an error oh i didn't", "start": 1644.559, "duration": 3.521 }, { "text": "realize i should detect that and then go", "start": 1646.159, "duration": 3.601 }, { "text": "back and improve your code but of course", "start": 1648.08, "duration": 3.52 }, { "text": "if you read the documentation you", "start": 1649.76, "duration": 3.36 }, { "text": "ingrain some of the lessons learned from", "start": 1651.6, "duration": 3.52 }, { "text": "the past you'll get into the habit of", "start": 1653.12, "duration": 3.76 }, { "text": "trying and checking for some of these", "start": 1655.12, "duration": 3.76 }, { "text": "exceptions yourself so let me solve this", "start": 1656.88, "duration": 4.399 }, { "text": "in one possible way as you proposed here", "start": 1658.88, "duration": 4.24 }, { "text": "let's try to handle this exception as", "start": 1661.279, "duration": 3.76 }, { "text": "follows let me go ahead now and instead", "start": 1663.12, "duration": 4.159 }, { "text": "of just blindly calling this print line", "start": 1665.039, "duration": 3.441 }, { "text": "let me try", "start": 1667.279, "duration": 3.681 }, { "text": "to print out hello my name is such and", "start": 1668.48, "duration": 5.04 }, { "text": "such except if there is an issue", "start": 1670.96, "duration": 5.599 }, { "text": "specifically an index error then what do", "start": 1673.52, "duration": 4.8 }, { "text": "i want to go ahead and do i'm going to", "start": 1676.559, "duration": 4.561 }, { "text": "say something like too few arguments i", "start": 1678.32, "duration": 4.719 }, { "text": "could be more explanatory than that but", "start": 1681.12, "duration": 3.84 }, { "text": "for now i'm just going to explain to the", "start": 1683.039, "duration": 3.76 }, { "text": "user that they gave me too few arguments", "start": 1684.96, "duration": 4.56 }, { "text": "too few words at the prompt so now it's", "start": 1686.799, "duration": 4.88 }, { "text": "still not going to work in quite the way", "start": 1689.52, "duration": 3.759 }, { "text": "i want i'm still not going to be able to", "start": 1691.679, "duration": 3.12 }, { "text": "generate their name tag but at least", "start": 1693.279, "duration": 2.88 }, { "text": "they're not going to see some cryptic", "start": 1694.799, "duration": 2.961 }, { "text": "error message and think that they", "start": 1696.159, "duration": 3.841 }, { "text": "themselves broke the program let me go", "start": 1697.76, "duration": 4.0 }, { "text": "ahead now and run python of name.pi", "start": 1700.0, "duration": 4.24 }, { "text": "enter and too few arguments okay let me", "start": 1701.76, "duration": 4.639 }, { "text": "go ahead now and do python of name.pi", "start": 1704.24, "duration": 5.12 }, { "text": "and type in my name david and now we're", "start": 1706.399, "duration": 5.52 }, { "text": "back in business and i see that my name", "start": 1709.36, "duration": 4.24 }, { "text": "is on the screen too", "start": 1711.919, "duration": 4.081 }, { "text": "but strictly speaking i don't have to", "start": 1713.6, "duration": 4.48 }, { "text": "try to do this i could actually be a", "start": 1716.0, "duration": 4.399 }, { "text": "little more defensive in writing this", "start": 1718.08, "duration": 4.88 }, { "text": "code and maybe i could check whether or", "start": 1720.399, "duration": 5.361 }, { "text": "not the user has indeed provided a name", "start": 1722.96, "duration": 5.199 }, { "text": "or multiple names at the prompt so as to", "start": 1725.76, "duration": 4.72 }, { "text": "give them more refined error messages as", "start": 1728.159, "duration": 4.481 }, { "text": "well so how might i do this well let me", "start": 1730.48, "duration": 4.88 }, { "text": "go and undo the exception handling i've", "start": 1732.64, "duration": 4.639 }, { "text": "added and why don't i instead more", "start": 1735.36, "duration": 4.24 }, { "text": "modestly try to do this let me go ahead", "start": 1737.279, "duration": 5.201 }, { "text": "and introduce a conditional here if the", "start": 1739.6, "duration": 5.76 }, { "text": "length of cis.rgv", "start": 1742.48, "duration": 6.24 }, { "text": "is less than two or equivalently equal", "start": 1745.36, "duration": 5.6 }, { "text": "to just one value but i'll just stick", "start": 1748.72, "duration": 4.079 }, { "text": "with less than two for now", "start": 1750.96, "duration": 5.04 }, { "text": "then go ahead and print out too few", "start": 1752.799, "duration": 5.521 }, { "text": "arguments so i want ultimately two", "start": 1756.0, "duration": 4.399 }, { "text": "arguments i want the name of the program", "start": 1758.32, "duration": 4.16 }, { "text": "at location zero and i want the name of", "start": 1760.399, "duration": 4.081 }, { "text": "the human at location one so that's a", "start": 1762.48, "duration": 3.84 }, { "text": "total of two arguments so if i have", "start": 1764.48, "duration": 3.76 }, { "text": "fewer than two arguments let's tell the", "start": 1766.32, "duration": 4.16 }, { "text": "user with this print line l if the", "start": 1768.24, "duration": 4.48 }, { "text": "length of sys.rgv", "start": 1770.48, "duration": 4.4 }, { "text": "is say greater than two like they typed", "start": 1772.72, "duration": 3.679 }, { "text": "in too many words at the prompt well", "start": 1774.88, "duration": 4.24 }, { "text": "let's tell them print quote unquote too", "start": 1776.399, "duration": 5.76 }, { "text": "many arguments else if they did get it", "start": 1779.12, "duration": 4.799 }, { "text": "right and they gave me exactly two", "start": 1782.159, "duration": 4.481 }, { "text": "arguments else let's go ahead and print", "start": 1783.919, "duration": 4.48 }, { "text": "what i actually care about all right let", "start": 1786.64, "duration": 3.36 }, { "text": "me go down to my terminal window here", "start": 1788.399, "duration": 5.041 }, { "text": "and run python of name.pi and voila", "start": 1790.0, "duration": 5.279 }, { "text": "a completely different type of error", "start": 1793.44, "duration": 3.839 }, { "text": "this one a syntax error which we've seen", "start": 1795.279, "duration": 4.241 }, { "text": "in the past now a syntax error recall is", "start": 1797.279, "duration": 4.64 }, { "text": "me a culpa like i messed up here and i", "start": 1799.52, "duration": 5.12 }, { "text": "wrote invalid syntax and so no amount of", "start": 1801.919, "duration": 4.961 }, { "text": "conditionals or exception handling is", "start": 1804.64, "duration": 3.68 }, { "text": "really going to catch this one i need to", "start": 1806.88, "duration": 3.039 }, { "text": "go back and just get my program to work", "start": 1808.32, "duration": 3.28 }, { "text": "because it's not running at all well let", "start": 1809.919, "duration": 4.0 }, { "text": "me go up here and see", "start": 1811.6, "duration": 5.36 }, { "text": "line 4 is the issue and indeed it looks", "start": 1813.919, "duration": 5.76 }, { "text": "like i have an unterminated string here", "start": 1816.96, "duration": 4.56 }, { "text": "i need to go ahead and now add this", "start": 1819.679, "duration": 3.921 }, { "text": "double quote so let me go ahead now when", "start": 1821.52, "duration": 4.08 }, { "text": "with that red herring gone let me rerun", "start": 1823.6, "duration": 4.24 }, { "text": "python of name dot pi and hit enter and", "start": 1825.6, "duration": 4.64 }, { "text": "now we see too few arguments okay maybe", "start": 1827.84, "duration": 4.16 }, { "text": "it wants my full name let me go ahead", "start": 1830.24, "duration": 4.0 }, { "text": "now and run python of name dot pi david", "start": 1832.0, "duration": 5.44 }, { "text": "malin typing in both words after the", "start": 1834.24, "duration": 5.28 }, { "text": "name of the file and hit enter and now", "start": 1837.44, "duration": 4.0 }, { "text": "of course it's too many arguments fine", "start": 1839.52, "duration": 4.32 }, { "text": "now i'll oblige and do python of name.pi", "start": 1841.44, "duration": 4.56 }, { "text": "and just david and there we have it my", "start": 1843.84, "duration": 4.4 }, { "text": "name tag printed on the screen so", "start": 1846.0, "duration": 3.84 }, { "text": "strictly speaking we don't have to", "start": 1848.24, "duration": 3.439 }, { "text": "handle exceptions if we can be a little", "start": 1849.84, "duration": 3.68 }, { "text": "smarter about it and just check for the", "start": 1851.679, "duration": 3.36 }, { "text": "things that we're worried about", "start": 1853.52, "duration": 3.44 }, { "text": "especially if we want to give the user", "start": 1855.039, "duration": 3.52 }, { "text": "more refined advice we don't want to", "start": 1856.96, "duration": 3.52 }, { "text": "just tell them no something went wrong", "start": 1858.559, "duration": 3.761 }, { "text": "or we don't want to pass we want to tell", "start": 1860.48, "duration": 4.48 }, { "text": "them no that's too few or no that's too", "start": 1862.32, "duration": 4.56 }, { "text": "many we have conditionals in our", "start": 1864.96, "duration": 4.8 }, { "text": "vocabulary already via which we can now", "start": 1866.88, "duration": 4.88 }, { "text": "express that well let me pause here and", "start": 1869.76, "duration": 4.08 }, { "text": "see if there's any questions now on how", "start": 1871.76, "duration": 4.0 }, { "text": "we handled the error before with the", "start": 1873.84, "duration": 4.24 }, { "text": "index error or how now we're just", "start": 1875.76, "duration": 5.12 }, { "text": "proactively avoiding all index errors", "start": 1878.08, "duration": 5.52 }, { "text": "all together by just checking first is", "start": 1880.88, "duration": 4.639 }, { "text": "it too few is it too many or is it", "start": 1883.6, "duration": 4.72 }, { "text": "exactly what we want oh yeah thank you", "start": 1885.519, "duration": 4.961 }, { "text": "um so i was wondering you you touched", "start": 1888.32, "duration": 5.28 }, { "text": "upon kind of using your full name um", "start": 1890.48, "duration": 5.84 }, { "text": "could we could we then um", "start": 1893.6, "duration": 4.16 }, { "text": "is there a way", "start": 1896.32, "duration": 4.16 }, { "text": "going forwards that perhaps we", "start": 1897.76, "duration": 4.32 }, { "text": "have people that want their full names", "start": 1900.48, "duration": 3.6 }, { "text": "and want their just their first name", "start": 1902.08, "duration": 4.319 }, { "text": "that we separate that into like oh this", "start": 1904.08, "duration": 4.719 }, { "text": "person has full name this person has", "start": 1906.399, "duration": 4.64 }, { "text": "just the one name", "start": 1908.799, "duration": 4.88 }, { "text": "absolutely and allow me to", "start": 1911.039, "duration": 4.48 }, { "text": "allow me to propose we come back to that", "start": 1913.679, "duration": 3.84 }, { "text": "support for multiple names", "start": 1915.519, "duration": 3.681 }, { "text": "but indeed we could do that and i should", "start": 1917.519, "duration": 4.561 }, { "text": "know too though we can support full", "start": 1919.2, "duration": 5.199 }, { "text": "names right now if i do this instead of", "start": 1922.08, "duration": 4.719 }, { "text": "typing in david spacemailin which is", "start": 1924.399, "duration": 4.481 }, { "text": "problematic because again by definition", "start": 1926.799, "duration": 5.521 }, { "text": "of how argv works each word ends up in a", "start": 1928.88, "duration": 5.84 }, { "text": "specific location in the list but if i", "start": 1932.32, "duration": 4.4 }, { "text": "add quotes single quotes or double", "start": 1934.72, "duration": 4.559 }, { "text": "quotes at the command line now python", "start": 1936.72, "duration": 4.4 }, { "text": "will view this as two total things the", "start": 1939.279, "duration": 3.921 }, { "text": "name of the file and this full name and", "start": 1941.12, "duration": 3.679 }, { "text": "now when i hit enter i don't see the", "start": 1943.2, "duration": 3.92 }, { "text": "quotes the whole thing is passed in as", "start": 1944.799, "duration": 4.321 }, { "text": "my full name and if i want to adapt this", "start": 1947.12, "duration": 3.679 }, { "text": "further for multiple people we'll be", "start": 1949.12, "duration": 3.84 }, { "text": "able to do that as well other questions", "start": 1950.799, "duration": 5.441 }, { "text": "now on this version with if elif else or", "start": 1952.96, "duration": 5.839 }, { "text": "on accept before", "start": 1956.24, "duration": 4.96 }, { "text": "i want to i want to ask you", "start": 1958.799, "duration": 5.201 }, { "text": "can we use multiple else statement can", "start": 1961.2, "duration": 4.8 }, { "text": "you use multiple else's statements no", "start": 1964.0, "duration": 4.0 }, { "text": "else is the last catch-all statement", "start": 1966.0, "duration": 4.24 }, { "text": "that you can have you can have multiple", "start": 1968.0, "duration": 5.039 }, { "text": "l if statements in the middle but not", "start": 1970.24, "duration": 6.279 }, { "text": "multiple elses", "start": 1973.039, "duration": 3.48 }, { "text": "all right", "start": 1976.799, "duration": 2.48 }, { "text": "all right well let's turn our attention", "start": 1977.84, "duration": 2.8 }, { "text": "back now to this code and see if we", "start": 1979.279, "duration": 3.361 }, { "text": "can't refine it a bit more by adding in", "start": 1980.64, "duration": 3.759 }, { "text": "some additional functionality that we", "start": 1982.64, "duration": 4.24 }, { "text": "get with modules like the sys module one", "start": 1984.399, "duration": 4.081 }, { "text": "of the things i don't love about this", "start": 1986.88, "duration": 3.36 }, { "text": "version of the code even though arguably", "start": 1988.48, "duration": 3.919 }, { "text": "it is now correct", "start": 1990.24, "duration": 4.48 }, { "text": "is that the essence of my program which", "start": 1992.399, "duration": 4.481 }, { "text": "is just to print out the name tag is", "start": 1994.72, "duration": 4.559 }, { "text": "kind of relegated to this else clause", "start": 1996.88, "duration": 5.2 }, { "text": "and that's fine logically it's correct", "start": 1999.279, "duration": 5.12 }, { "text": "but generally speaking there's something", "start": 2002.08, "duration": 4.4 }, { "text": "nice about keeping all of your error", "start": 2004.399, "duration": 5.28 }, { "text": "handling separate from the code that you", "start": 2006.48, "duration": 5.36 }, { "text": "really care about having all of these", "start": 2009.679, "duration": 4.161 }, { "text": "ifs lifts perhaps at the top of your", "start": 2011.84, "duration": 4.16 }, { "text": "code that are checking to make sure that", "start": 2013.84, "duration": 4.24 }, { "text": "all of the data is as expected but then", "start": 2016.0, "duration": 4.48 }, { "text": "it would be nice if only for design's", "start": 2018.08, "duration": 4.88 }, { "text": "sake not to sort of hide in this else", "start": 2020.48, "duration": 4.559 }, { "text": "statement the actual code that you care", "start": 2022.96, "duration": 4.16 }, { "text": "about i would prefer for instance to do", "start": 2025.039, "duration": 4.48 }, { "text": "something logically like this i could", "start": 2027.12, "duration": 4.64 }, { "text": "check for errors up top", "start": 2029.519, "duration": 4.961 }, { "text": "and then down here print the name tags", "start": 2031.76, "duration": 4.08 }, { "text": "it would be nice if those are sort of", "start": 2034.48, "duration": 3.84 }, { "text": "distinct blocks of code all of which are", "start": 2035.84, "duration": 4.559 }, { "text": "here left aligned but there's a problem", "start": 2038.32, "duration": 4.16 }, { "text": "with what i've just done here", "start": 2040.399, "duration": 5.201 }, { "text": "logically what bug did i just introduced", "start": 2042.48, "duration": 5.52 }, { "text": "by getting rid of the else", "start": 2045.6, "duration": 5.2 }, { "text": "and introducing line 10 on its own with", "start": 2048.0, "duration": 5.04 }, { "text": "no indentation outside of the", "start": 2050.8, "duration": 3.76 }, { "text": "conditional", "start": 2053.04, "duration": 3.44 }, { "text": "what bug have i just introduced what", "start": 2054.56, "duration": 4.799 }, { "text": "mistake to be clear", "start": 2056.48, "duration": 5.919 }, { "text": "um name error ironically it's a name", "start": 2059.359, "duration": 5.601 }, { "text": "error but not a name error exception", "start": 2062.399, "duration": 5.52 }, { "text": "it's an error with my name but", "start": 2064.96, "duration": 5.439 }, { "text": "i think you're frozen for me it's going", "start": 2067.919, "duration": 4.641 }, { "text": "to raise an exception because even", "start": 2070.399, "duration": 3.921 }, { "text": "though i'm checking the length of", "start": 2072.56, "duration": 4.319 }, { "text": "sys.rgv up top and even though i'm", "start": 2074.32, "duration": 4.48 }, { "text": "checking it again for being greater than", "start": 2076.879, "duration": 3.841 }, { "text": "two not just less than two but greater", "start": 2078.8, "duration": 4.319 }, { "text": "i'm still then blindly and incorrectly", "start": 2080.72, "duration": 4.56 }, { "text": "assuming it's now going to exist so just", "start": 2083.119, "duration": 4.56 }, { "text": "to be clear if i run python of name dot", "start": 2085.28, "duration": 4.799 }, { "text": "pi and i don't type any arguments i've", "start": 2087.679, "duration": 4.72 }, { "text": "got too few i think i'm going to see", "start": 2090.079, "duration": 4.721 }, { "text": "that i have too few but i'm also going", "start": 2092.399, "duration": 4.72 }, { "text": "to see that same exception at the very", "start": 2094.8, "duration": 3.84 }, { "text": "top of my terminal windows output", "start": 2097.119, "duration": 3.121 }, { "text": "there's my error message too few", "start": 2098.64, "duration": 4.0 }, { "text": "arguments but again on line 10 i blindly", "start": 2100.24, "duration": 5.359 }, { "text": "proceed to still index into my list at", "start": 2102.64, "duration": 6.0 }, { "text": "location one which does not exist so it", "start": 2105.599, "duration": 4.881 }, { "text": "turns out there's a better way to handle", "start": 2108.64, "duration": 3.199 }, { "text": "errors like this especially if you're", "start": 2110.48, "duration": 3.68 }, { "text": "writing a program in python that's just", "start": 2111.839, "duration": 4.641 }, { "text": "meant to run briefly and then exit", "start": 2114.16, "duration": 4.959 }, { "text": "anyway but maybe we could start to exit", "start": 2116.48, "duration": 5.599 }, { "text": "prematurely if the program itself just", "start": 2119.119, "duration": 4.801 }, { "text": "can't proceed if the user has not given", "start": 2122.079, "duration": 3.841 }, { "text": "us the data we want perhaps we should", "start": 2123.92, "duration": 4.96 }, { "text": "just exit the program earlier than we", "start": 2125.92, "duration": 5.04 }, { "text": "might otherwise so let me go ahead and", "start": 2128.88, "duration": 3.84 }, { "text": "do this let me go ahead and remove my", "start": 2130.96, "duration": 3.68 }, { "text": "comments so as to focus only on the code", "start": 2132.72, "duration": 5.44 }, { "text": "here and let me propose that instead of", "start": 2134.64, "duration": 6.0 }, { "text": "just printing quote unquote too few", "start": 2138.16, "duration": 4.32 }, { "text": "arguments i'm going to use one other", "start": 2140.64, "duration": 4.0 }, { "text": "function that comes with the sys module", "start": 2142.48, "duration": 5.44 }, { "text": "i'm going to go ahead and call sys.exit", "start": 2144.64, "duration": 4.959 }, { "text": "and as the name suggests it's going to", "start": 2147.92, "duration": 3.84 }, { "text": "do exactly that with the systems help", "start": 2149.599, "duration": 4.561 }, { "text": "it's going to exit my program then and", "start": 2151.76, "duration": 5.68 }, { "text": "there on line four why is that okay well", "start": 2154.16, "duration": 4.88 }, { "text": "if you gave me too few arguments i have", "start": 2157.44, "duration": 3.6 }, { "text": "nothing more to say to you the user i", "start": 2159.04, "duration": 4.319 }, { "text": "might as well exit a bit prematurely and", "start": 2161.04, "duration": 4.319 }, { "text": "i can do this as well on line six let's", "start": 2163.359, "duration": 3.361 }, { "text": "go ahead and not just print that but", "start": 2165.359, "duration": 3.841 }, { "text": "sys.exit quote-unquote too many", "start": 2166.72, "duration": 4.24 }, { "text": "arguments print out that message and", "start": 2169.2, "duration": 3.6 }, { "text": "just exit right there", "start": 2170.96, "duration": 4.0 }, { "text": "now i can trust that by the time i get", "start": 2172.8, "duration": 5.279 }, { "text": "to line eight every error condition has", "start": 2174.96, "duration": 5.44 }, { "text": "been checked for and so it's safe for me", "start": 2178.079, "duration": 5.52 }, { "text": "to assume that there is in fact an item", "start": 2180.4, "duration": 6.8 }, { "text": "at location one in sys.rgv so let me go", "start": 2183.599, "duration": 5.361 }, { "text": "ahead now and run this", "start": 2187.2, "duration": 4.879 }, { "text": "python of name dot pi enter too few", "start": 2188.96, "duration": 5.44 }, { "text": "arguments but i'm back at my prompt", "start": 2192.079, "duration": 4.481 }, { "text": "nothing more has happened let me run it", "start": 2194.4, "duration": 4.8 }, { "text": "again python of name dot pi david malen", "start": 2196.56, "duration": 5.279 }, { "text": "with no quotes enter too many arguments", "start": 2199.2, "duration": 5.12 }, { "text": "is now printed here finally python of", "start": 2201.839, "duration": 5.841 }, { "text": "name dot pi just david enter hello my", "start": 2204.32, "duration": 6.08 }, { "text": "name is david so we have then insists", "start": 2207.68, "duration": 4.48 }, { "text": "two forms of functionality now we have", "start": 2210.4, "duration": 4.08 }, { "text": "access to this variable sys.rgv this", "start": 2212.16, "duration": 4.4 }, { "text": "argument vector that gives me all of the", "start": 2214.48, "duration": 3.599 }, { "text": "words that were typed at the prompt", "start": 2216.56, "duration": 3.76 }, { "text": "including the program's own file name", "start": 2218.079, "duration": 4.0 }, { "text": "and it turns out if we read further in", "start": 2220.32, "duration": 3.12 }, { "text": "the documentation there's an exit", "start": 2222.079, "duration": 3.28 }, { "text": "function that can take different types", "start": 2223.44, "duration": 4.159 }, { "text": "of inputs but if i pass it a string like", "start": 2225.359, "duration": 4.401 }, { "text": "this it will indeed print that string", "start": 2227.599, "duration": 4.721 }, { "text": "for me and then exit from my program", "start": 2229.76, "duration": 3.92 }, { "text": "then in there", "start": 2232.32, "duration": 4.24 }, { "text": "questions now on exiting from programs", "start": 2233.68, "duration": 4.159 }, { "text": "like this", "start": 2236.56, "duration": 3.84 }, { "text": "to be clear all of this time once python", "start": 2237.839, "duration": 4.481 }, { "text": "gets to the bottom of your file it's", "start": 2240.4, "duration": 3.679 }, { "text": "going to exit anyway so i'm using", "start": 2242.32, "duration": 4.0 }, { "text": "sys.exit now just to make sure that i", "start": 2244.079, "duration": 5.121 }, { "text": "exit earlier than otherwise um my", "start": 2246.32, "duration": 5.84 }, { "text": "question is about the cis that are", "start": 2249.2, "duration": 4.399 }, { "text": "our v", "start": 2252.16, "duration": 4.64 }, { "text": "so is that capable of accepting or", "start": 2253.599, "duration": 6.401 }, { "text": "taking multiple elements at once let's", "start": 2256.8, "duration": 4.64 }, { "text": "say for example", "start": 2260.0, "duration": 6.32 }, { "text": "a python name that pi david malin i'm", "start": 2261.44, "duration": 7.919 }, { "text": "a male uh 20 years old and if let's say", "start": 2266.32, "duration": 5.92 }, { "text": "i only want to access your name which is", "start": 2269.359, "duration": 5.601 }, { "text": "at the first index and then your", "start": 2272.24, "duration": 3.839 }, { "text": "your", "start": 2274.96, "duration": 3.52 }, { "text": "your age is brought say at the sixth", "start": 2276.079, "duration": 4.121 }, { "text": "index can i say", "start": 2278.48, "duration": 3.28 }, { "text": "cis.rb", "start": 2280.2, "duration": 2.919 }, { "text": "one", "start": 2281.76, "duration": 4.24 }, { "text": "and another one for six to access what i", "start": 2283.119, "duration": 4.0 }, { "text": "just want", "start": 2286.0, "duration": 4.32 }, { "text": "is that possible for cis harvey", "start": 2287.119, "duration": 5.681 }, { "text": "uh short answer yes i think if i", "start": 2290.32, "duration": 3.759 }, { "text": "understand your question correctly", "start": 2292.8, "duration": 3.2 }, { "text": "whereby you're proposing to have many", "start": 2294.079, "duration": 3.601 }, { "text": "words at the end of the command and you", "start": 2296.0, "duration": 3.52 }, { "text": "want to access those individual words", "start": 2297.68, "duration": 4.56 }, { "text": "absolutely at some point it gets a", "start": 2299.52, "duration": 4.64 }, { "text": "little fragile i would say if you're", "start": 2302.24, "duration": 4.08 }, { "text": "typing so many words at the prompt that", "start": 2304.16, "duration": 5.199 }, { "text": "the order really matters and so it turns", "start": 2306.32, "duration": 4.4 }, { "text": "out there's a lot of programs and", "start": 2309.359, "duration": 2.801 }, { "text": "there's functionality in python that can", "start": 2310.72, "duration": 4.16 }, { "text": "allow you to provide those values like", "start": 2312.16, "duration": 5.04 }, { "text": "name or age or any number of other", "start": 2314.88, "duration": 6.239 }, { "text": "fields in any order you want but pass in", "start": 2317.2, "duration": 5.919 }, { "text": "a bit more information textually that", "start": 2321.119, "duration": 3.681 }, { "text": "tells the program how you want to use it", "start": 2323.119, "duration": 3.761 }, { "text": "so in short what you're describing is", "start": 2324.8, "duration": 4.16 }, { "text": "possible and let me do a small", "start": 2326.88, "duration": 4.88 }, { "text": "incarnation of it as follows let me", "start": 2328.96, "duration": 5.36 }, { "text": "propose that we go back to my code here", "start": 2331.76, "duration": 4.24 }, { "text": "and let's propose that we actually now", "start": 2334.32, "duration": 3.84 }, { "text": "want to support multiple values at the", "start": 2336.0, "duration": 4.0 }, { "text": "prompt so there's going to be no such", "start": 2338.16, "duration": 3.76 }, { "text": "thing as too many arguments suppose that", "start": 2340.0, "duration": 3.76 }, { "text": "i want to generate name tags not just", "start": 2341.92, "duration": 4.24 }, { "text": "for david but for david for carter for", "start": 2343.76, "duration": 4.56 }, { "text": "wrong shin for others in the group who", "start": 2346.16, "duration": 4.24 }, { "text": "all want their name tags as well so i'm", "start": 2348.32, "duration": 3.12 }, { "text": "going to go ahead and do this i'm going", "start": 2350.4, "duration": 2.959 }, { "text": "to get rid of my elif condition because", "start": 2351.44, "duration": 3.919 }, { "text": "i don't want to limit the maximum number", "start": 2353.359, "duration": 3.601 }, { "text": "of words that are typed at the prompt", "start": 2355.359, "duration": 4.321 }, { "text": "anymore i instead want to iterate over", "start": 2356.96, "duration": 4.8 }, { "text": "every", "start": 2359.68, "duration": 4.159 }, { "text": "name at the prompt so i'm going to say", "start": 2361.76, "duration": 6.4 }, { "text": "this for arg in sys.rgv", "start": 2363.839, "duration": 7.201 }, { "text": "go ahead and print out this time", "start": 2368.16, "duration": 3.84 }, { "text": "arg", "start": 2371.04, "duration": 2.88 }, { "text": "so what am i doing here well even though", "start": 2372.0, "duration": 3.839 }, { "text": "the syntax is a little different the", "start": 2373.92, "duration": 3.76 }, { "text": "idea is the same as before when we've", "start": 2375.839, "duration": 4.321 }, { "text": "had loops i'm using a for loop to", "start": 2377.68, "duration": 5.12 }, { "text": "iterate over a list the list in question", "start": 2380.16, "duration": 4.72 }, { "text": "here is sys.rgv", "start": 2382.8, "duration": 4.64 }, { "text": "arg is a variable that i'm creating on", "start": 2384.88, "duration": 4.239 }, { "text": "the fly the for loop is going to make", "start": 2387.44, "duration": 3.28 }, { "text": "sure that the first time through this", "start": 2389.119, "duration": 3.841 }, { "text": "loop r gets set to the first word on the", "start": 2390.72, "duration": 3.84 }, { "text": "command line the second time through the", "start": 2392.96, "duration": 2.879 }, { "text": "loop python python's going to make sure", "start": 2394.56, "duration": 2.799 }, { "text": "that arg is now set to the second thing", "start": 2395.839, "duration": 2.881 }, { "text": "on the command line and so forth that's", "start": 2397.359, "duration": 3.441 }, { "text": "just how a for loop works it updates the", "start": 2398.72, "duration": 3.92 }, { "text": "variable for us i don't have to call it", "start": 2400.8, "duration": 4.24 }, { "text": "arg i could call it name so long as i", "start": 2402.64, "duration": 4.64 }, { "text": "change it to name in both places but arg", "start": 2405.04, "duration": 3.92 }, { "text": "is reasonable if i'm iterating over", "start": 2407.28, "duration": 3.52 }, { "text": "arguments more generally", "start": 2408.96, "duration": 4.24 }, { "text": "if i now run this program though", "start": 2410.8, "duration": 4.64 }, { "text": "unfortunately there's a little bit of a", "start": 2413.2, "duration": 3.119 }, { "text": "bug", "start": 2415.44, "duration": 3.679 }, { "text": "even if i type in david and carter and", "start": 2416.319, "duration": 4.481 }, { "text": "wrong shin", "start": 2419.119, "duration": 6.161 }, { "text": "i'm not gonna get just three name tags", "start": 2420.8, "duration": 7.44 }, { "text": "in your mind does anyone see the bug i'm", "start": 2425.28, "duration": 5.52 }, { "text": "about to trip over it's not a huge deal", "start": 2428.24, "duration": 5.04 }, { "text": "if i've got enough name tags to go", "start": 2430.8, "duration": 4.72 }, { "text": "around but i'm gonna be wasting one", "start": 2433.28, "duration": 3.76 }, { "text": "because this is gonna print not three", "start": 2435.52, "duration": 4.319 }, { "text": "but four name tags whereby the first", "start": 2437.04, "duration": 4.96 }, { "text": "contains the name of the program itself", "start": 2439.839, "duration": 3.76 }, { "text": "maybe not a big deal maybe that's the", "start": 2442.0, "duration": 3.2 }, { "text": "sticker we don't bother handing out but", "start": 2443.599, "duration": 3.921 }, { "text": "it's wasteful and it does look wrong so", "start": 2445.2, "duration": 4.56 }, { "text": "how could we get access to", "start": 2447.52, "duration": 5.44 }, { "text": "not all four elements of argv but just a", "start": 2449.76, "duration": 5.359 }, { "text": "slice of argv and this is actually a", "start": 2452.96, "duration": 4.24 }, { "text": "technical term in python and some other", "start": 2455.119, "duration": 4.801 }, { "text": "languages to take a slice of a list", "start": 2457.2, "duration": 4.96 }, { "text": "means to take a subset of it maybe from", "start": 2459.92, "duration": 4.32 }, { "text": "the beginning maybe the middle maybe the", "start": 2462.16, "duration": 5.04 }, { "text": "end but a slice is a subset of a data", "start": 2464.24, "duration": 4.96 }, { "text": "structure like a list well how do i", "start": 2467.2, "duration": 4.159 }, { "text": "actually do this in code well", "start": 2469.2, "duration": 3.76 }, { "text": "in python it's actually very easy to", "start": 2471.359, "duration": 3.76 }, { "text": "take a slice of a list that is a subset", "start": 2472.96, "duration": 4.8 }, { "text": "thereof you can simply do this at the", "start": 2475.119, "duration": 5.041 }, { "text": "end of the list name sys.rgv in this", "start": 2477.76, "duration": 4.64 }, { "text": "case you can use square brackets and", "start": 2480.16, "duration": 3.84 }, { "text": "then in those square brackets you can", "start": 2482.4, "duration": 4.959 }, { "text": "specify the start and the end of the", "start": 2484.0, "duration": 5.839 }, { "text": "list that you want to retain i want to", "start": 2487.359, "duration": 4.48 }, { "text": "start at element one", "start": 2489.839, "duration": 4.561 }, { "text": "not zero i want to start at element 1", "start": 2491.839, "duration": 4.401 }, { "text": "and i want to just go to the end so i'm", "start": 2494.4, "duration": 3.36 }, { "text": "actually going to omit a second number", "start": 2496.24, "duration": 3.359 }, { "text": "altogether it's not necessary to have a", "start": 2497.76, "duration": 4.319 }, { "text": "second number but i do need that colon", "start": 2499.599, "duration": 4.161 }, { "text": "because this is going to give me a slice", "start": 2502.079, "duration": 3.201 }, { "text": "of the list it's going to give me a", "start": 2503.76, "duration": 2.88 }, { "text": "slice of the list that starts at", "start": 2505.28, "duration": 4.48 }, { "text": "location one not zero and the colon and", "start": 2506.64, "duration": 4.719 }, { "text": "then a blank just means it's going to", "start": 2509.76, "duration": 3.52 }, { "text": "give me everything else so this is", "start": 2511.359, "duration": 3.681 }, { "text": "equivalently going to slice off the", "start": 2513.28, "duration": 3.68 }, { "text": "first element of the list and give me a", "start": 2515.04, "duration": 4.0 }, { "text": "new list that contains just those three", "start": 2516.96, "duration": 4.32 }, { "text": "human names not the name of the file", "start": 2519.04, "duration": 4.64 }, { "text": "itself let me try running this again i'm", "start": 2521.28, "duration": 4.88 }, { "text": "going to run python of name dot pi david", "start": 2523.68, "duration": 4.72 }, { "text": "carter wrong shin this time hopefully", "start": 2526.16, "duration": 4.32 }, { "text": "i'm going to get three and only three", "start": 2528.4, "duration": 5.12 }, { "text": "name tags hitting enter and indeed i've", "start": 2530.48, "duration": 5.44 }, { "text": "done now just this so again using some", "start": 2533.52, "duration": 4.799 }, { "text": "relatively simple syntax in python we", "start": 2535.92, "duration": 4.159 }, { "text": "can use square brackets not just to go", "start": 2538.319, "duration": 3.841 }, { "text": "to specific elements like bracket zero", "start": 2540.079, "duration": 4.641 }, { "text": "or bracket one we can also get subsets", "start": 2542.16, "duration": 4.88 }, { "text": "of the list slices of the list by doing", "start": 2544.72, "duration": 5.28 }, { "text": "bracket something colon something where", "start": 2547.04, "duration": 4.64 }, { "text": "each of those somethings is a number the", "start": 2550.0, "duration": 2.96 }, { "text": "beginning or the end and they're", "start": 2551.68, "duration": 2.88 }, { "text": "optional depending on whether you want", "start": 2552.96, "duration": 4.399 }, { "text": "all of them or just some", "start": 2554.56, "duration": 5.6 }, { "text": "any questions now on this version which", "start": 2557.359, "duration": 4.161 }, { "text": "adds the loop", "start": 2560.16, "duration": 5.12 }, { "text": "and these slices with that new syntax", "start": 2561.52, "duration": 6.079 }, { "text": "can we slice starting from the end", "start": 2565.28, "duration": 5.12 }, { "text": "of the argument argument vector", "start": 2567.599, "duration": 4.72 }, { "text": "you can you can slice something from the", "start": 2570.4, "duration": 3.679 }, { "text": "end of the argument vector and this", "start": 2572.319, "duration": 4.241 }, { "text": "might uh this might blow one's mind a", "start": 2574.079, "duration": 5.441 }, { "text": "little bit let me go ahead and do this", "start": 2576.56, "duration": 4.96 }, { "text": "uh let's see let me go ahead and do", "start": 2579.52, "duration": 4.24 }, { "text": "negative one at the end using a negative", "start": 2581.52, "duration": 4.4 }, { "text": "number here and running the same command", "start": 2583.76, "duration": 4.319 }, { "text": "we've just uninvited wrong shin from", "start": 2585.92, "duration": 4.48 }, { "text": "receiving a name tag here so if you use", "start": 2588.079, "duration": 4.561 }, { "text": "a negative number it has the effect of", "start": 2590.4, "duration": 4.16 }, { "text": "counting to the uh in the other", "start": 2592.64, "duration": 4.479 }, { "text": "direction from the end of the list a", "start": 2594.56, "duration": 4.16 }, { "text": "good question there other questions now", "start": 2597.119, "duration": 3.361 }, { "text": "on slices on", "start": 2598.72, "duration": 4.96 }, { "text": "looping over sys.rgv", "start": 2600.48, "duration": 5.76 }, { "text": "hi uh so i remember very early on uh", "start": 2603.68, "duration": 4.32 }, { "text": "when we were talking about uh only", "start": 2606.24, "duration": 4.56 }, { "text": "having two decimal places in uh in an um", "start": 2608.0, "duration": 5.2 }, { "text": "float value um", "start": 2610.8, "duration": 3.36 }, { "text": "does this", "start": 2613.2, "duration": 3.84 }, { "text": "is is that in the same vein like um", "start": 2614.16, "duration": 6.64 }, { "text": "because we use the the colon point two f", "start": 2617.04, "duration": 6.48 }, { "text": "uh so that's is that the same thing then", "start": 2620.8, "duration": 5.279 }, { "text": "uh why would the f be included then", "start": 2623.52, "duration": 4.88 }, { "text": "in the point two f", "start": 2626.079, "duration": 4.161 }, { "text": "as opposed to here when you just have", "start": 2628.4, "duration": 3.679 }, { "text": "the numbers", "start": 2630.24, "duration": 3.839 }, { "text": "a really good question and it's just the", "start": 2632.079, "duration": 4.24 }, { "text": "short answer is that context matters so", "start": 2634.079, "duration": 4.561 }, { "text": "there's only so many keyboard keys on", "start": 2636.319, "duration": 4.241 }, { "text": "our keyboard and so we sometimes use the", "start": 2638.64, "duration": 3.84 }, { "text": "same symbols for different things so", "start": 2640.56, "duration": 4.48 }, { "text": "what you're alluding to is the format", "start": 2642.48, "duration": 4.639 }, { "text": "code in in fstring for actually", "start": 2645.04, "duration": 4.48 }, { "text": "formatting a number using a colon using", "start": 2647.119, "duration": 4.72 }, { "text": "a period using a number using the letter", "start": 2649.52, "duration": 4.96 }, { "text": "f and so forth and that is very specific", "start": 2651.839, "duration": 5.28 }, { "text": "to the f string feature of python this", "start": 2654.48, "duration": 4.72 }, { "text": "case has nothing to do with any of that", "start": 2657.119, "duration": 4.401 }, { "text": "syntax per se this is just using a colon", "start": 2659.2, "duration": 4.24 }, { "text": "in a different context to solve this", "start": 2661.52, "duration": 4.0 }, { "text": "problem to implement a slice the authors", "start": 2663.44, "duration": 3.919 }, { "text": "of python could have chosen another", "start": 2665.52, "duration": 3.599 }, { "text": "symbol but honestly looking down at my", "start": 2667.359, "duration": 3.361 }, { "text": "keyboard here we don't have that many to", "start": 2669.119, "duration": 3.441 }, { "text": "choose from that are easy to type so", "start": 2670.72, "duration": 3.52 }, { "text": "sometimes they have different meanings a", "start": 2672.56, "duration": 4.08 }, { "text": "good question as well allow me to", "start": 2674.24, "duration": 4.96 }, { "text": "propose now that we take things further", "start": 2676.64, "duration": 4.959 }, { "text": "and move away from using only those", "start": 2679.2, "duration": 4.56 }, { "text": "modules those libraries that python", "start": 2681.599, "duration": 4.561 }, { "text": "comes with to talk about more generally", "start": 2683.76, "duration": 4.64 }, { "text": "packages that exist one of the reasons", "start": 2686.16, "duration": 4.4 }, { "text": "that python is so popular and powerful", "start": 2688.4, "duration": 3.84 }, { "text": "these days is that there's a lot of", "start": 2690.56, "duration": 4.24 }, { "text": "third-party libraries out there as well", "start": 2692.24, "duration": 5.04 }, { "text": "otherwise known as packages strictly", "start": 2694.8, "duration": 6.08 }, { "text": "speaking python itself has a term of art", "start": 2697.28, "duration": 6.559 }, { "text": "called a package which is a module", "start": 2700.88, "duration": 4.719 }, { "text": "essentially that's implemented in a", "start": 2703.839, "duration": 4.401 }, { "text": "folder not just a file but a folder but", "start": 2705.599, "duration": 4.961 }, { "text": "more generally a package is a", "start": 2708.24, "duration": 5.119 }, { "text": "third-party library that you that i can", "start": 2710.56, "duration": 5.12 }, { "text": "install on our own mac or pc or our", "start": 2713.359, "duration": 6.48 }, { "text": "cloud server and gain access to even", "start": 2715.68, "duration": 4.159 }, { "text": "and this is a website that is searchable", "start": 2731.28, "duration": 4.0 }, { "text": "via the command line as well as via the", "start": 2733.28, "duration": 3.92 }, { "text": "web that allows you to download and", "start": 2735.28, "duration": 4.559 }, { "text": "install all sorts of packages even cs50", "start": 2737.2, "duration": 4.72 }, { "text": "has some of its own packages", "start": 2739.839, "duration": 4.561 }, { "text": "in services like these now there's a fun", "start": 2741.92, "duration": 3.84 }, { "text": "one out there that's a throwback to a", "start": 2744.4, "duration": 2.8 }, { "text": "command that's been around for years in", "start": 2745.76, "duration": 4.079 }, { "text": "command line environments called cowsei", "start": 2747.2, "duration": 5.119 }, { "text": "causee is a package in python that", "start": 2749.839, "duration": 5.041 }, { "text": "allows you to have a cow say something", "start": 2752.319, "duration": 4.8 }, { "text": "on your screen if curious to read up on", "start": 2754.88, "duration": 5.52 }, { "text": "it its own documentation is on pipi.org", "start": 2757.119, "duration": 5.841 }, { "text": "specifically at this url here but how do", "start": 2760.4, "duration": 4.88 }, { "text": "you actually get the package into your", "start": 2762.96, "duration": 4.32 }, { "text": "system well technically you could figure", "start": 2765.28, "duration": 4.4 }, { "text": "out how to download the file and maybe", "start": 2767.28, "duration": 4.079 }, { "text": "unzip it and put it into the right", "start": 2769.68, "duration": 4.159 }, { "text": "location on your mac or pc but nowadays", "start": 2771.359, "duration": 4.641 }, { "text": "a lot of languages python among them has", "start": 2773.839, "duration": 4.081 }, { "text": "what's called its own package manager", "start": 2776.0, "duration": 3.76 }, { "text": "this one here called pip which is just", "start": 2777.92, "duration": 5.6 }, { "text": "one so pip is a program that generally", "start": 2779.76, "duration": 6.24 }, { "text": "comes with python itself nowadays that", "start": 2783.52, "duration": 4.799 }, { "text": "allows you to install packages onto your", "start": 2786.0, "duration": 4.88 }, { "text": "own macs or pcs or cloud environment by", "start": 2788.319, "duration": 4.561 }, { "text": "just running a command and then voila", "start": 2790.88, "duration": 4.88 }, { "text": "you have access to a whole new library", "start": 2792.88, "duration": 4.719 }, { "text": "in python that didn't come with python", "start": 2795.76, "duration": 4.079 }, { "text": "itself but now it's available on your", "start": 2797.599, "duration": 3.281 }, { "text": "system", "start": 2799.839, "duration": 3.201 }, { "text": "for you let's go back to vs code here", "start": 2800.88, "duration": 3.52 }, { "text": "and in my terminal window i'm going to", "start": 2803.04, "duration": 4.079 }, { "text": "go ahead and type pip install", "start": 2804.4, "duration": 5.04 }, { "text": "cow say now what's going on here pip is", "start": 2807.119, "duration": 4.401 }, { "text": "the command the package manager and i", "start": 2809.44, "duration": 4.56 }, { "text": "want to install what package the package", "start": 2811.52, "duration": 4.0 }, { "text": "called cow say i'm going to go ahead and", "start": 2814.0, "duration": 4.16 }, { "text": "hit enter here and after a little bit of", "start": 2815.52, "duration": 4.799 }, { "text": "output it has successfully installed cow", "start": 2818.16, "duration": 4.24 }, { "text": "say now what does that mean that means i", "start": 2820.319, "duration": 4.401 }, { "text": "can now go about importing this into my", "start": 2822.4, "duration": 4.24 }, { "text": "own code well let's go ahead and see", "start": 2824.72, "duration": 3.2 }, { "text": "what this means let me go ahead and", "start": 2826.64, "duration": 3.76 }, { "text": "create a new file with code called say", "start": 2827.92, "duration": 4.24 }, { "text": "dot pi because i want something to be", "start": 2830.4, "duration": 4.08 }, { "text": "said on the screen and in my new tab", "start": 2832.16, "duration": 4.159 }, { "text": "here i'm going to go ahead and import", "start": 2834.48, "duration": 5.04 }, { "text": "cowse which presumably is now installed", "start": 2836.319, "duration": 5.361 }, { "text": "i'm now going to import sys as well", "start": 2839.52, "duration": 3.92 }, { "text": "because i'd like to use some command", "start": 2841.68, "duration": 3.439 }, { "text": "line arguments in this program just so", "start": 2843.44, "duration": 3.44 }, { "text": "that i can run it quickly and without", "start": 2845.119, "duration": 3.841 }, { "text": "using the input function i can get the", "start": 2846.88, "duration": 4.64 }, { "text": "user's name immediately from the prompt", "start": 2848.96, "duration": 4.0 }, { "text": "and let me go ahead and do this i'm", "start": 2851.52, "duration": 2.72 }, { "text": "going to do a bit of error checking", "start": 2852.96, "duration": 3.04 }, { "text": "proactively this time and rather than", "start": 2854.24, "duration": 3.52 }, { "text": "use less than or greater than i'm this", "start": 2856.0, "duration": 3.68 }, { "text": "time going to say if the length of", "start": 2857.76, "duration": 4.079 }, { "text": "sys.org v does", "start": 2859.68, "duration": 4.639 }, { "text": "does equal two so if the human is", "start": 2861.839, "duration": 4.321 }, { "text": "provided just the name of the program", "start": 2864.319, "duration": 4.081 }, { "text": "and their own first name we're good to", "start": 2866.16, "duration": 3.04 }, { "text": "go", "start": 2868.4, "duration": 2.8 }, { "text": "i'm going to do the following i'm going", "start": 2869.2, "duration": 4.399 }, { "text": "to call a function called", "start": 2871.2, "duration": 3.359 }, { "text": "cow", "start": 2873.599, "duration": 3.52 }, { "text": "in the package called cow say and i'm", "start": 2874.559, "duration": 5.201 }, { "text": "going to pass in a string hello", "start": 2877.119, "duration": 5.281 }, { "text": "comma and then as in the past i'm going", "start": 2879.76, "duration": 4.079 }, { "text": "to pass in just one string because", "start": 2882.4, "duration": 3.04 }, { "text": "according to its documentation it's not", "start": 2883.839, "duration": 3.52 }, { "text": "like print i can't pass in comma this", "start": 2885.44, "duration": 4.0 }, { "text": "comma that i can only pass in one string", "start": 2887.359, "duration": 3.921 }, { "text": "so i'm going to concatenate the contents", "start": 2889.44, "duration": 6.399 }, { "text": "of sis.org v bracket one so long as then", "start": 2891.28, "duration": 7.6 }, { "text": "i type in my name david after the name", "start": 2895.839, "duration": 5.041 }, { "text": "of this program it should end up in", "start": 2898.88, "duration": 5.199 }, { "text": "sys.org v1 in which case this line 5 of", "start": 2900.88, "duration": 5.12 }, { "text": "code should concatenate hello with my", "start": 2904.079, "duration": 4.081 }, { "text": "name with a space in between and", "start": 2906.0, "duration": 4.48 }, { "text": "apparently a cow is going to say it so", "start": 2908.16, "duration": 4.0 }, { "text": "let's see what happens here", "start": 2910.48, "duration": 4.0 }, { "text": "let me go ahead and clear my screen and", "start": 2912.16, "duration": 4.399 }, { "text": "increase the size of my terminal window", "start": 2914.48, "duration": 4.32 }, { "text": "let me go ahead and run python of say", "start": 2916.559, "duration": 6.0 }, { "text": "dot pi and type my name david and enter", "start": 2918.8, "duration": 5.92 }, { "text": "there is the program called kausei it", "start": 2922.559, "duration": 4.401 }, { "text": "literally has a cow say something on the", "start": 2924.72, "duration": 3.92 }, { "text": "screen and this is a throwback to a", "start": 2926.96, "duration": 3.44 }, { "text": "program from yesteryear that tended to", "start": 2928.64, "duration": 4.16 }, { "text": "come with a lot of systems", "start": 2930.4, "duration": 4.48 }, { "text": "this is otherwise known as ascii art", "start": 2932.8, "duration": 4.08 }, { "text": "it's a textual way using just keys on", "start": 2934.88, "duration": 4.719 }, { "text": "your keyboard to print pictures of sorts", "start": 2936.88, "duration": 4.719 }, { "text": "on the screen now we can really go down", "start": 2939.599, "duration": 3.52 }, { "text": "the rabbit hole here and there's", "start": 2941.599, "duration": 3.361 }, { "text": "questionable academic value of doing so", "start": 2943.119, "duration": 3.761 }, { "text": "so i'll do so just once turns out the", "start": 2944.96, "duration": 3.84 }, { "text": "cow say package comes with other", "start": 2946.88, "duration": 4.32 }, { "text": "functions as well one of those functions", "start": 2948.8, "duration": 5.12 }, { "text": "for instance is t-rex and if i now", "start": 2951.2, "duration": 4.639 }, { "text": "increase the size of my terminal window", "start": 2953.92, "duration": 3.36 }, { "text": "we'll perhaps see where we're going with", "start": 2955.839, "duration": 3.361 }, { "text": "this let me now run again python of", "start": 2957.28, "duration": 4.079 }, { "text": "say.pi this time let me not provide my", "start": 2959.2, "duration": 4.08 }, { "text": "name just to see if it's broken", "start": 2961.359, "duration": 4.0 }, { "text": "it's still okay because we have that if", "start": 2963.28, "duration": 5.76 }, { "text": "condition if the length of sys.rgv", "start": 2965.359, "duration": 5.76 }, { "text": "equals equals 2 and only if it equals", "start": 2969.04, "duration": 3.92 }, { "text": "equals 2 do we do anything that's why", "start": 2971.119, "duration": 3.841 }, { "text": "we're not seeing anything here let me go", "start": 2972.96, "duration": 4.639 }, { "text": "ahead and cooperate now say.pi space", "start": 2974.96, "duration": 6.24 }, { "text": "david and it's no longer a cow but", "start": 2977.599, "duration": 7.441 }, { "text": "if i zoom out on my screen a t-rex why", "start": 2981.2, "duration": 5.52 }, { "text": "just because these are the things you", "start": 2985.04, "duration": 3.2 }, { "text": "can do once you know how to program you", "start": 2986.72, "duration": 2.879 }, { "text": "can even package them up and make them", "start": 2988.24, "duration": 3.2 }, { "text": "freely available to others as open", "start": 2989.599, "duration": 3.921 }, { "text": "source software for us it's", "start": 2991.44, "duration": 4.0 }, { "text": "demonstrative of a feature more", "start": 2993.52, "duration": 3.92 }, { "text": "generally here namely being able to", "start": 2995.44, "duration": 3.76 }, { "text": "install these third-party packages and", "start": 2997.44, "duration": 4.32 }, { "text": "how you might do so in python now i'll", "start": 2999.2, "duration": 4.0 }, { "text": "leave this up on the screen for a moment", "start": 3001.76, "duration": 3.44 }, { "text": "and see if there's any questions about", "start": 3003.2, "duration": 5.359 }, { "text": "cows or tyrannosaurus rex's or packages", "start": 3005.2, "duration": 5.68 }, { "text": "more generally", "start": 3008.559, "duration": 4.0 }, { "text": "i'm really qualified to speak to just", "start": 3010.88, "duration": 3.6 }, { "text": "one of those", "start": 3012.559, "duration": 5.121 }, { "text": "hi um i've got two questions it's a bit", "start": 3014.48, "duration": 6.16 }, { "text": "earlier than what it's supposed to be um", "start": 3017.68, "duration": 5.52 }, { "text": "so the first question is", "start": 3020.64, "duration": 3.52 }, { "text": "the", "start": 3023.2, "duration": 4.32 }, { "text": "packages that you're calling um", "start": 3024.16, "duration": 4.24 }, { "text": "to", "start": 3027.52, "duration": 3.44 }, { "text": "use in the program", "start": 3028.4, "duration": 5.36 }, { "text": "are they the same as", "start": 3030.96, "duration": 3.76 }, { "text": "um", "start": 3033.76, "duration": 4.24 }, { "text": "let's say because i'm doing java", "start": 3034.72, "duration": 6.72 }, { "text": "the same as calling a class of a java", "start": 3038.0, "duration": 4.48 }, { "text": "file", "start": 3041.44, "duration": 4.32 }, { "text": "in order to use its functions", "start": 3042.48, "duration": 6.079 }, { "text": "and my second question is", "start": 3045.76, "duration": 5.359 }, { "text": "what's the actual purpose of using", "start": 3048.559, "duration": 5.441 }, { "text": "command line arguments as you use", "start": 3051.119, "duration": 3.761 }, { "text": "because", "start": 3054.0, "duration": 5.28 }, { "text": "it's not really the best way to", "start": 3054.88, "duration": 7.12 }, { "text": "as you say be user friendly", "start": 3059.28, "duration": 4.24 }, { "text": "where as in", "start": 3062.0, "duration": 4.24 }, { "text": "let's say the person who's", "start": 3063.52, "duration": 5.36 }, { "text": "using the program doesn't know what it", "start": 3066.24, "duration": 5.2 }, { "text": "what they want what the program's asking", "start": 3068.88, "duration": 3.52 }, { "text": "them", "start": 3071.44, "duration": 2.56 }, { "text": "really good questions the first question", "start": 3072.4, "duration": 3.84 }, { "text": "about the comparison with java python", "start": 3074.0, "duration": 4.64 }, { "text": "packages are similar to java packages", "start": 3076.24, "duration": 4.079 }, { "text": "where you have something dot something", "start": 3078.64, "duration": 3.28 }, { "text": "dot something at the top of your program", "start": 3080.319, "duration": 3.28 }, { "text": "that gives you access to a class or", "start": 3081.92, "duration": 3.919 }, { "text": "something else python itself supports", "start": 3083.599, "duration": 4.801 }, { "text": "classes more on those down the road and", "start": 3085.839, "duration": 4.72 }, { "text": "you can do very similar things in python", "start": 3088.4, "duration": 4.08 }, { "text": "as you can do with java but the analog", "start": 3090.559, "duration": 4.481 }, { "text": "really is python packages to java", "start": 3092.48, "duration": 4.879 }, { "text": "packages here as for command line", "start": 3095.04, "duration": 4.64 }, { "text": "arguments you ask a good question why do", "start": 3097.359, "duration": 3.601 }, { "text": "we use them especially if they're", "start": 3099.68, "duration": 3.2 }, { "text": "literally yes user friendly they're a", "start": 3100.96, "duration": 4.399 }, { "text": "little less user friendly to people who", "start": 3102.88, "duration": 5.04 }, { "text": "aren't in this zoom to be honest you and", "start": 3105.359, "duration": 4.161 }, { "text": "i as we learn more and more about", "start": 3107.92, "duration": 3.12 }, { "text": "programming and more about command line", "start": 3109.52, "duration": 3.36 }, { "text": "arguments i daresay will become more", "start": 3111.04, "duration": 4.64 }, { "text": "comfortable with and tend to prefer the", "start": 3112.88, "duration": 4.8 }, { "text": "ability to customize commands using", "start": 3115.68, "duration": 3.76 }, { "text": "these command line arguments why", "start": 3117.68, "duration": 3.76 }, { "text": "productivity it tends to make you faster", "start": 3119.44, "duration": 3.119 }, { "text": "because you get into the habit of", "start": 3121.44, "duration": 2.8 }, { "text": "knowing exactly how you can configure", "start": 3122.559, "duration": 3.841 }, { "text": "your software without having to manually", "start": 3124.24, "duration": 4.56 }, { "text": "answer questions and case in point all", "start": 3126.4, "duration": 3.84 }, { "text": "of this time", "start": 3128.8, "duration": 3.84 }, { "text": "have we been running python of something", "start": 3130.24, "duration": 5.04 }, { "text": "dot pi you could imagine not doing that", "start": 3132.64, "duration": 4.56 }, { "text": "you could imagine typing only python", "start": 3135.28, "duration": 3.92 }, { "text": "hitting enter and then you're prompted", "start": 3137.2, "duration": 3.28 }, { "text": "for the name of the file you want to run", "start": 3139.2, "duration": 3.2 }, { "text": "so you type in something.pi and then it", "start": 3140.48, "duration": 4.4 }, { "text": "runs not a big deal but i i would argue", "start": 3142.4, "duration": 4.0 }, { "text": "that over time you're going to get a", "start": 3144.88, "duration": 3.12 }, { "text": "little tired of that tedium and you", "start": 3146.4, "duration": 3.28 }, { "text": "would much prefer to just automate the", "start": 3148.0, "duration": 3.44 }, { "text": "command again and again and again", "start": 3149.68, "duration": 3.439 }, { "text": "especially with little conveniences like", "start": 3151.44, "duration": 3.76 }, { "text": "being able to hit up and down in your", "start": 3153.119, "duration": 4.0 }, { "text": "keyboard history so as to rerun those", "start": 3155.2, "duration": 4.32 }, { "text": "same commands automation is big too if", "start": 3157.119, "duration": 4.48 }, { "text": "you emerge from a class like this and", "start": 3159.52, "duration": 4.96 }, { "text": "start using python to automate processes", "start": 3161.599, "duration": 4.561 }, { "text": "at work or for personal projects or the", "start": 3164.48, "duration": 3.599 }, { "text": "like the ability to specify all of your", "start": 3166.16, "duration": 3.439 }, { "text": "inputs on the one line just means you", "start": 3168.079, "duration": 4.321 }, { "text": "can get work done more quickly so hands", "start": 3169.599, "duration": 4.881 }, { "text": "down absolutely using command line", "start": 3172.4, "duration": 5.199 }, { "text": "arguments is a more arcane uh feature of", "start": 3174.48, "duration": 5.359 }, { "text": "systems that most of us are no longer as", "start": 3177.599, "duration": 4.24 }, { "text": "familiar with because of windows and mac", "start": 3179.839, "duration": 3.76 }, { "text": "os and other operating systems that have", "start": 3181.839, "duration": 4.24 }, { "text": "buttons and guise and menus but the more", "start": 3183.599, "duration": 4.24 }, { "text": "comfortable get you get with programming", "start": 3186.079, "duration": 3.841 }, { "text": "i dare say the more you will tend to", "start": 3187.839, "duration": 4.081 }, { "text": "prefer these capabilities because they", "start": 3189.92, "duration": 5.04 }, { "text": "allow you to do things more quickly", "start": 3191.92, "duration": 4.96 }, { "text": "with that said allow me to propose that", "start": 3194.96, "duration": 5.44 }, { "text": "we take a turn toward yet another", "start": 3196.88, "duration": 5.92 }, { "text": "package that's particularly popular and", "start": 3200.4, "duration": 4.8 }, { "text": "just as easy to install all toward an", "start": 3202.8, "duration": 5.12 }, { "text": "end of using apis now apis are not", "start": 3205.2, "duration": 4.72 }, { "text": "something that's python specific more", "start": 3207.92, "duration": 4.399 }, { "text": "generally an api is an application", "start": 3209.92, "duration": 4.8 }, { "text": "programming interface and it can refer", "start": 3212.319, "duration": 5.52 }, { "text": "to python files and functions but often", "start": 3214.72, "duration": 5.44 }, { "text": "apis really refer to third-party", "start": 3217.839, "duration": 4.801 }, { "text": "services that you and i can write code", "start": 3220.16, "duration": 3.84 }, { "text": "that talk to", "start": 3222.64, "duration": 3.76 }, { "text": "many apis but not all live on the", "start": 3224.0, "duration": 4.4 }, { "text": "internet these days so that so long as", "start": 3226.4, "duration": 3.6 }, { "text": "you have a browser or so long as you", "start": 3228.4, "duration": 3.52 }, { "text": "have some experience with python", "start": 3230.0, "duration": 3.359 }, { "text": "programming or programming in any", "start": 3231.92, "duration": 3.679 }, { "text": "language you can write code that in", "start": 3233.359, "duration": 5.2 }, { "text": "effect pretends to be a browser connects", "start": 3235.599, "duration": 6.401 }, { "text": "to that third-party api on a server and", "start": 3238.559, "duration": 4.961 }, { "text": "downloads some data that you can then", "start": 3242.0, "duration": 3.76 }, { "text": "incorporate into your own program now", "start": 3243.52, "duration": 4.48 }, { "text": "how do you do this well python has a", "start": 3245.76, "duration": 4.079 }, { "text": "very popular package that you can", "start": 3248.0, "duration": 4.72 }, { "text": "install via pip called requests the", "start": 3249.839, "duration": 5.601 }, { "text": "requests library allows you to make web", "start": 3252.72, "duration": 5.599 }, { "text": "requests internet requests using python", "start": 3255.44, "duration": 5.679 }, { "text": "code essentially as though you were a", "start": 3258.319, "duration": 5.28 }, { "text": "browser yourself you can automate there", "start": 3261.119, "duration": 4.401 }, { "text": "for the retrieval of urls that start", "start": 3263.599, "duration": 5.681 }, { "text": "with http or https the documentation for", "start": 3265.52, "duration": 5.76 }, { "text": "this library is a url like this but it", "start": 3269.28, "duration": 3.76 }, { "text": "too can be installed at the command line", "start": 3271.28, "duration": 3.12 }, { "text": "and even though it's third party it's", "start": 3273.04, "duration": 3.279 }, { "text": "one of the most popular and commonly", "start": 3274.4, "duration": 4.0 }, { "text": "used packages out there in python and", "start": 3276.319, "duration": 4.24 }, { "text": "this too is one of the reasons again", "start": 3278.4, "duration": 4.64 }, { "text": "that python is so popular there's just", "start": 3280.559, "duration": 4.321 }, { "text": "so many solutions to problems that you", "start": 3283.04, "duration": 4.079 }, { "text": "and i have or are invariably going to", "start": 3284.88, "duration": 4.4 }, { "text": "have when we write projects of our own", "start": 3287.119, "duration": 4.641 }, { "text": "there's just a really vibrant ecosystem", "start": 3289.28, "duration": 4.319 }, { "text": "a really vibrant community of open", "start": 3291.76, "duration": 4.319 }, { "text": "source software that's that easy for us", "start": 3293.599, "duration": 4.48 }, { "text": "to install let me go back to my terminal", "start": 3296.079, "duration": 4.48 }, { "text": "window now and run pip install requests", "start": 3298.079, "duration": 4.321 }, { "text": "in order to install this package on my", "start": 3300.559, "duration": 3.441 }, { "text": "own system and after some lines of", "start": 3302.4, "duration": 3.439 }, { "text": "output i'll see that it's successfully", "start": 3304.0, "duration": 3.92 }, { "text": "installed now let's go ahead and create", "start": 3305.839, "duration": 4.201 }, { "text": "a new file here for instance", "start": 3307.92, "duration": 3.679 }, { "text": "itunes.pi", "start": 3310.04, "duration": 3.96 }, { "text": "it turns out that apple has its own api", "start": 3311.599, "duration": 4.081 }, { "text": "for their itunes service the software", "start": 3314.0, "duration": 2.96 }, { "text": "that provides you with the ability to", "start": 3315.68, "duration": 2.96 }, { "text": "download and search for music and songs", "start": 3316.96, "duration": 3.68 }, { "text": "and other information as well and it", "start": 3318.64, "duration": 3.919 }, { "text": "turns out that let me go back over to my", "start": 3320.64, "duration": 4.0 }, { "text": "computer here and open up a browser like", "start": 3322.559, "duration": 4.081 }, { "text": "chrome and let me go ahead and visit", "start": 3324.64, "duration": 5.8 }, { "text": "this url here https colon slash", "start": 3326.64, "duration": 5.439 }, { "text": "itunes.apple.com", "start": 3330.44, "duration": 2.52 }, { "text": "search", "start": 3332.079, "duration": 3.28 }, { "text": "question mark entity equals song", "start": 3332.96, "duration": 5.359 }, { "text": "ampersand limit equals one ampersand", "start": 3335.359, "duration": 5.281 }, { "text": "term equals weezer now i constructed", "start": 3338.319, "duration": 4.081 }, { "text": "this url manually by reading the", "start": 3340.64, "duration": 4.08 }, { "text": "documentation for apple's api", "start": 3342.4, "duration": 4.0 }, { "text": "application programming interface for", "start": 3344.72, "duration": 3.92 }, { "text": "itunes and what they told me is that if", "start": 3346.4, "duration": 4.32 }, { "text": "i want to search for information about", "start": 3348.64, "duration": 4.8 }, { "text": "songs in their database i should specify", "start": 3350.72, "duration": 4.879 }, { "text": "entity equal song so that it's songs and", "start": 3353.44, "duration": 3.919 }, { "text": "not albums or artists or something like", "start": 3355.599, "duration": 3.121 }, { "text": "that if i just want to get back", "start": 3357.359, "duration": 3.121 }, { "text": "information on one song i'm going to", "start": 3358.72, "duration": 4.16 }, { "text": "provide limit equals one and if the band", "start": 3360.48, "duration": 4.079 }, { "text": "i want to search for the artist is", "start": 3362.88, "duration": 4.08 }, { "text": "weezer i should specify term equals", "start": 3364.559, "duration": 5.121 }, { "text": "weezer so with this if i go ahead and", "start": 3366.96, "duration": 5.119 }, { "text": "hit enter and visit this url i actually", "start": 3369.68, "duration": 4.24 }, { "text": "end up with a text file in my downloads", "start": 3372.079, "duration": 4.081 }, { "text": "folder on my mac if i go ahead and open", "start": 3373.92, "duration": 3.679 }, { "text": "that text file that my browser just", "start": 3376.16, "duration": 3.12 }, { "text": "downloaded will see all of this text", "start": 3377.599, "duration": 3.441 }, { "text": "here which at first glance might look a", "start": 3379.28, "duration": 3.6 }, { "text": "bit cryptic but it actually follows a", "start": 3381.04, "duration": 4.0 }, { "text": "pattern notice this curly brace at the", "start": 3382.88, "duration": 4.479 }, { "text": "start and notice this closed curly brace", "start": 3385.04, "duration": 4.4 }, { "text": "at the end notice this open square", "start": 3387.359, "duration": 4.0 }, { "text": "bracket here and notice this close", "start": 3389.44, "duration": 4.879 }, { "text": "square bracket here and in between those", "start": 3391.359, "duration": 4.96 }, { "text": "pieces of syntax are a whole bunch of", "start": 3394.319, "duration": 4.081 }, { "text": "strings and values in fact a whole bunch", "start": 3396.319, "duration": 4.401 }, { "text": "of key value pairs what we're looking at", "start": 3398.4, "duration": 4.399 }, { "text": "here is a standard text format known as", "start": 3400.72, "duration": 5.04 }, { "text": "json javascript object notation which", "start": 3402.799, "duration": 4.481 }, { "text": "yes is technically related to yet", "start": 3405.76, "duration": 2.96 }, { "text": "another programming language called", "start": 3407.28, "duration": 4.24 }, { "text": "javascript but json itself is typically", "start": 3408.72, "duration": 5.839 }, { "text": "used nowadays as a language agnostic", "start": 3411.52, "duration": 5.52 }, { "text": "format for exchanging data between", "start": 3414.559, "duration": 4.8 }, { "text": "computers by language agnostic i mean", "start": 3417.04, "duration": 3.84 }, { "text": "you don't have to use javascript you can", "start": 3419.359, "duration": 3.76 }, { "text": "use python or any other language to read", "start": 3420.88, "duration": 4.56 }, { "text": "json or write it as well and it's a", "start": 3423.119, "duration": 4.401 }, { "text": "completely text based format which means", "start": 3425.44, "duration": 4.72 }, { "text": "that if i visit that url with my browser", "start": 3427.52, "duration": 4.4 }, { "text": "what gets downloaded is just a bunch of", "start": 3430.16, "duration": 4.24 }, { "text": "text but that text is formatted in a", "start": 3431.92, "duration": 5.04 }, { "text": "standard way using curly braces and", "start": 3434.4, "duration": 5.12 }, { "text": "square brackets using quotes and some", "start": 3436.96, "duration": 4.879 }, { "text": "colons that ultimately contains all of", "start": 3439.52, "duration": 4.72 }, { "text": "the information in apple's database on", "start": 3441.839, "duration": 4.48 }, { "text": "weezer's song at least the first one", "start": 3444.24, "duration": 4.16 }, { "text": "because i limited it to one in their", "start": 3446.319, "duration": 3.921 }, { "text": "database and that's an api an", "start": 3448.4, "duration": 3.439 }, { "text": "application programming interface a", "start": 3450.24, "duration": 4.319 }, { "text": "mechanism whereby i can access data on", "start": 3451.839, "duration": 4.48 }, { "text": "someone else's server and somehow", "start": 3454.559, "duration": 3.841 }, { "text": "integrate it into my own", "start": 3456.319, "duration": 4.641 }, { "text": "program now of course my browser chrome", "start": 3458.4, "duration": 4.0 }, { "text": "is not something i wrote i should", "start": 3460.96, "duration": 3.2 }, { "text": "actually write some python code that", "start": 3462.4, "duration": 4.24 }, { "text": "perhaps pretends to be a browser to grab", "start": 3464.16, "duration": 4.8 }, { "text": "the same data so let's do that let me go", "start": 3466.64, "duration": 3.919 }, { "text": "back to vs code here and let me write a", "start": 3468.96, "duration": 4.72 }, { "text": "program with code itunes.pi and we're", "start": 3470.559, "duration": 5.04 }, { "text": "going to write some code by which i can", "start": 3473.68, "duration": 3.439 }, { "text": "then use", "start": 3475.599, "duration": 4.881 }, { "text": "the itunes api and in turn python to get", "start": 3477.119, "duration": 5.761 }, { "text": "information about any band that i might", "start": 3480.48, "duration": 4.319 }, { "text": "want i'm going to go here and import", "start": 3482.88, "duration": 4.64 }, { "text": "first the requests library which i", "start": 3484.799, "duration": 4.721 }, { "text": "installed earlier in order to make those", "start": 3487.52, "duration": 4.64 }, { "text": "http requests i'm going to go ahead and", "start": 3489.52, "duration": 4.88 }, { "text": "import the sys library by which i'll", "start": 3492.16, "duration": 4.0 }, { "text": "have the ability to use command line", "start": 3494.4, "duration": 4.08 }, { "text": "arguments like specification of the band", "start": 3496.16, "duration": 4.399 }, { "text": "that i want to search for if not weezer", "start": 3498.48, "duration": 3.839 }, { "text": "and then down here i'm going to go ahead", "start": 3500.559, "duration": 5.121 }, { "text": "and insert some error checking to say if", "start": 3502.319, "duration": 5.921 }, { "text": "the length of sys.rgv", "start": 3505.68, "duration": 5.6 }, { "text": "does not equal 2 so if the user does not", "start": 3508.24, "duration": 4.48 }, { "text": "provide me with the name of the file", "start": 3511.28, "duration": 3.92 }, { "text": "they want to run and the name of a band", "start": 3512.72, "duration": 4.399 }, { "text": "and that's it you know what let's just", "start": 3515.2, "duration": 4.32 }, { "text": "go ahead and exit for now i could", "start": 3517.119, "duration": 4.081 }, { "text": "provide a more explanatory message but", "start": 3519.52, "duration": 2.96 }, { "text": "for now i'm going to keep things simple", "start": 3521.2, "duration": 3.76 }, { "text": "and just exit the program prematurely so", "start": 3522.48, "duration": 5.359 }, { "text": "that i can trust hereafter that sys.rt", "start": 3524.96, "duration": 4.32 }, { "text": "has what i want", "start": 3527.839, "duration": 4.0 }, { "text": "and now i have the opportunity to use", "start": 3529.28, "duration": 4.72 }, { "text": "the requests library to write some", "start": 3531.839, "duration": 3.921 }, { "text": "python code that effectively is", "start": 3534.0, "duration": 4.64 }, { "text": "pretending to be a web browser so as to", "start": 3535.76, "duration": 5.92 }, { "text": "connect to that same https url on", "start": 3538.64, "duration": 5.439 }, { "text": "apple's own server so now that i've", "start": 3541.68, "duration": 4.08 }, { "text": "guaranteed that the user has typed in", "start": 3544.079, "duration": 3.921 }, { "text": "not just the name of the file but also", "start": 3545.76, "duration": 4.4 }, { "text": "the name of a band at the prompt giving", "start": 3548.0, "duration": 4.96 }, { "text": "me a length of 2 for sys.rgv let's go", "start": 3550.16, "duration": 5.439 }, { "text": "ahead and execute requests.get which is", "start": 3552.96, "duration": 5.04 }, { "text": "a function inside of the request package", "start": 3555.599, "duration": 4.321 }, { "text": "that will literally get some response", "start": 3558.0, "duration": 4.079 }, { "text": "from a server and the url that i want to", "start": 3559.92, "duration": 4.879 }, { "text": "get is exactly the same as before https", "start": 3562.079, "duration": 4.081 }, { "text": "colon slash", "start": 3564.799, "duration": 3.361 }, { "text": "itunes.apple.com", "start": 3566.16, "duration": 5.04 }, { "text": "search question mark entity equal song", "start": 3568.16, "duration": 6.0 }, { "text": "ampersand limit equals one ampersand", "start": 3571.2, "duration": 5.68 }, { "text": "term equals previously weezer but let's", "start": 3574.16, "duration": 4.639 }, { "text": "make this program a little interactive", "start": 3576.88, "duration": 4.479 }, { "text": "and actually allow the human to specify", "start": 3578.799, "duration": 4.481 }, { "text": "at the command line what artists they'd", "start": 3581.359, "duration": 3.681 }, { "text": "like to search for so i'm going to go", "start": 3583.28, "duration": 4.4 }, { "text": "ahead and close my quote early and just", "start": 3585.04, "duration": 5.279 }, { "text": "append using the concatenation operator", "start": 3587.68, "duration": 5.52 }, { "text": "as in the past sis.rgv", "start": 3590.319, "duration": 5.52 }, { "text": "bracket 1. and now it'd actually be nice", "start": 3593.2, "duration": 4.8 }, { "text": "to store the response from the server in", "start": 3595.839, "duration": 3.601 }, { "text": "a variable so i'm going to go ahead and", "start": 3598.0, "duration": 4.799 }, { "text": "say response equals and to store all of", "start": 3599.44, "duration": 4.56 }, { "text": "the response that comes back from the", "start": 3602.799, "duration": 3.201 }, { "text": "server in a variable called response", "start": 3604.0, "duration": 3.76 }, { "text": "down here now i'd like to just", "start": 3606.0, "duration": 3.44 }, { "text": "understand what the server is returning", "start": 3607.76, "duration": 3.76 }, { "text": "to me to make sure i know how next to", "start": 3609.44, "duration": 3.84 }, { "text": "proceed so this isn't going to be very", "start": 3611.52, "duration": 3.039 }, { "text": "pretty yet but i'm going to go ahead and", "start": 3613.28, "duration": 2.519 }, { "text": "print out", "start": 3614.559, "duration": 4.0 }, { "text": "response.json which ensures that the", "start": 3615.799, "duration": 4.841 }, { "text": "data i'm getting back is formatted on my", "start": 3618.559, "duration": 4.721 }, { "text": "screen as exactly that json the same", "start": 3620.64, "duration": 5.36 }, { "text": "text format as we saw on my screen it's", "start": 3623.28, "duration": 4.799 }, { "text": "not a useful program yet i'm really just", "start": 3626.0, "duration": 3.92 }, { "text": "learning along the way but let me go", "start": 3628.079, "duration": 3.361 }, { "text": "ahead now and increase the size of my", "start": 3629.92, "duration": 4.12 }, { "text": "terminal window and run python of", "start": 3631.44, "duration": 5.04 }, { "text": "itunes.pi and type in the name of a band", "start": 3634.04, "duration": 4.759 }, { "text": "like weezer and hit enter", "start": 3636.48, "duration": 4.48 }, { "text": "and what we see on the screen formatted", "start": 3638.799, "duration": 4.56 }, { "text": "almost the same as before is exactly", "start": 3640.96, "duration": 4.879 }, { "text": "that same text but what you'll see here", "start": 3643.359, "duration": 4.72 }, { "text": "is that this has been standardized now", "start": 3645.839, "duration": 5.361 }, { "text": "as a python dictionary what indeed apple", "start": 3648.079, "duration": 5.441 }, { "text": "is returning is technically a json", "start": 3651.2, "duration": 5.04 }, { "text": "response javascript object notation but", "start": 3653.52, "duration": 5.279 }, { "text": "python the request library is converting", "start": 3656.24, "duration": 5.28 }, { "text": "it to a python dictionary which happens", "start": 3658.799, "duration": 4.961 }, { "text": "to use wonderfully coincidentally almost", "start": 3661.52, "duration": 4.96 }, { "text": "the same syntax it uses curly braces to", "start": 3663.76, "duration": 4.48 }, { "text": "represent the dictionary here and a", "start": 3666.48, "duration": 3.44 }, { "text": "closed curly brace to represent the end", "start": 3668.24, "duration": 4.559 }, { "text": "of it here for any lists therein it uses", "start": 3669.92, "duration": 4.72 }, { "text": "a square bracket here and a closed", "start": 3672.799, "duration": 4.881 }, { "text": "square bracket down here it uses quotes", "start": 3674.64, "duration": 4.4 }, { "text": "single quotes in this case or", "start": 3677.68, "duration": 3.36 }, { "text": "equivalently double quotes to represent", "start": 3679.04, "duration": 5.039 }, { "text": "the keys in that dictionary and after a", "start": 3681.04, "duration": 6.0 }, { "text": "colon it stores the value of that key", "start": 3684.079, "duration": 4.72 }, { "text": "and so you'll see that indeed we have a", "start": 3687.04, "duration": 4.72 }, { "text": "result count key whose value is one but", "start": 3688.799, "duration": 5.201 }, { "text": "then a more interesting result key", "start": 3691.76, "duration": 4.96 }, { "text": "called results whose value is this", "start": 3694.0, "duration": 5.839 }, { "text": "entire list of data now honestly this is", "start": 3696.72, "duration": 4.96 }, { "text": "such a big blob of text that it's going", "start": 3699.839, "duration": 3.201 }, { "text": "to take me forever to wrap my mind", "start": 3701.68, "duration": 3.439 }, { "text": "around what i'm seeing so let me propose", "start": 3703.04, "duration": 4.64 }, { "text": "temporarily we use another library in", "start": 3705.119, "duration": 4.96 }, { "text": "python that will allow me to format my", "start": 3707.68, "duration": 4.8 }, { "text": "data a little more cleanly it turns out", "start": 3710.079, "duration": 4.72 }, { "text": "that python also comes with a special", "start": 3712.48, "duration": 4.96 }, { "text": "library uh called json that allows you", "start": 3714.799, "duration": 5.04 }, { "text": "to manipulate json data and even just", "start": 3717.44, "duration": 4.48 }, { "text": "printing print it that is formatted in a", "start": 3719.839, "duration": 3.441 }, { "text": "way that's going to be way easier for", "start": 3721.92, "duration": 3.439 }, { "text": "you and i to understand so let me go", "start": 3723.28, "duration": 4.64 }, { "text": "back to my code here let me shrink my", "start": 3725.359, "duration": 4.0 }, { "text": "terminal window", "start": 3727.92, "duration": 3.679 }, { "text": "and let me propose that just temporarily", "start": 3729.359, "duration": 4.72 }, { "text": "again we do this let me import this", "start": 3731.599, "duration": 4.48 }, { "text": "additional library json which comes with", "start": 3734.079, "duration": 3.601 }, { "text": "python so i don't need to install it", "start": 3736.079, "duration": 4.081 }, { "text": "manually with pip and let me go ahead", "start": 3737.68, "duration": 5.119 }, { "text": "now and not just print out response.json", "start": 3740.16, "duration": 4.56 }, { "text": "which was that big blob of hard to", "start": 3742.799, "duration": 4.161 }, { "text": "understand text let me go ahead and use", "start": 3744.72, "duration": 4.839 }, { "text": "one other function here called", "start": 3746.96, "duration": 6.72 }, { "text": "json.dump s for dump string and pass to", "start": 3749.559, "duration": 6.681 }, { "text": "that function that response dot json", "start": 3753.68, "duration": 4.399 }, { "text": "return value so again i'm just", "start": 3756.24, "duration": 4.319 }, { "text": "introducing another function who i claim", "start": 3758.079, "duration": 4.561 }, { "text": "it has a purpose in life of pretty", "start": 3760.559, "duration": 4.321 }, { "text": "printing nicely formatting on the screen", "start": 3762.64, "duration": 4.32 }, { "text": "the exact same information i know this", "start": 3764.88, "duration": 3.679 }, { "text": "from the documentation having done this", "start": 3766.96, "duration": 3.52 }, { "text": "before but i'd like things to be nicely", "start": 3768.559, "duration": 3.601 }, { "text": "indented and according to the", "start": 3770.48, "duration": 3.68 }, { "text": "documentation if i pass in a named", "start": 3772.16, "duration": 5.12 }, { "text": "parameter of indent equals two that's", "start": 3774.16, "duration": 4.72 }, { "text": "going to indent everything at least two", "start": 3777.28, "duration": 3.6 }, { "text": "spaces i could do four or something else", "start": 3778.88, "duration": 3.76 }, { "text": "but it's going to be enough to help me", "start": 3780.88, "duration": 4.08 }, { "text": "wrap my mind around what the data is i'm", "start": 3782.64, "duration": 4.0 }, { "text": "getting back because again i'm just", "start": 3784.96, "duration": 3.68 }, { "text": "learning along with you so let me", "start": 3786.64, "duration": 3.439 }, { "text": "increase the size of my terminal window", "start": 3788.64, "duration": 3.919 }, { "text": "again let me run python of itunes.pi and", "start": 3790.079, "duration": 4.24 }, { "text": "again let's search for weezer and hit", "start": 3792.559, "duration": 3.921 }, { "text": "enter and now notice", "start": 3794.319, "duration": 4.0 }, { "text": "it's still a little bit cryptic because", "start": 3796.48, "duration": 4.639 }, { "text": "there's a lot going on here but my gosh", "start": 3798.319, "duration": 5.681 }, { "text": "i can totally read this more easily now", "start": 3801.119, "duration": 4.96 }, { "text": "notice now that i still see the first", "start": 3804.0, "duration": 4.079 }, { "text": "curly brace which means hey this is a", "start": 3806.079, "duration": 4.0 }, { "text": "dictionary in python a collection of", "start": 3808.079, "duration": 4.72 }, { "text": "keys and values the first key is called", "start": 3810.079, "duration": 4.561 }, { "text": "result count it happens to be displayed", "start": 3812.799, "duration": 3.681 }, { "text": "in double quotes now but that's just an", "start": 3814.64, "duration": 3.28 }, { "text": "issue of formatting it could be double", "start": 3816.48, "duration": 3.359 }, { "text": "or single so long as we're consistent", "start": 3817.92, "duration": 5.04 }, { "text": "the value of that key is one why well i", "start": 3819.839, "duration": 5.28 }, { "text": "told the url to only limit the responses", "start": 3822.96, "duration": 4.079 }, { "text": "to one weezer song so i've gotten a", "start": 3825.119, "duration": 4.081 }, { "text": "result set of one if i increase that", "start": 3827.039, "duration": 4.721 }, { "text": "limit i could probably get more then the", "start": 3829.2, "duration": 4.159 }, { "text": "interesting part of this response is", "start": 3831.76, "duration": 3.88 }, { "text": "really the data itself notice in the", "start": 3833.359, "duration": 5.361 }, { "text": "results key here there's a really big", "start": 3835.64, "duration": 7.08 }, { "text": "value the value is a python list as", "start": 3838.72, "duration": 5.52 }, { "text": "implied", "start": 3842.72, "duration": 3.52 }, { "text": "by this square bracket what does this", "start": 3844.24, "duration": 4.48 }, { "text": "list contain well i know from skimming", "start": 3846.24, "duration": 4.48 }, { "text": "it earlier that this contains one", "start": 3848.72, "duration": 4.8 }, { "text": "dictionary and that's why we see another", "start": 3850.72, "duration": 4.8 }, { "text": "curly brace here", "start": 3853.52, "duration": 3.839 }, { "text": "so again if this gets a little more", "start": 3855.52, "duration": 3.36 }, { "text": "complicated keep in mind that a", "start": 3857.359, "duration": 4.081 }, { "text": "dictionary is just a collection of key", "start": 3858.88, "duration": 5.199 }, { "text": "value pairs and python uses curly braces", "start": 3861.44, "duration": 4.159 }, { "text": "to indicate as much", "start": 3864.079, "duration": 3.921 }, { "text": "it is perfectly reasonable for a", "start": 3865.599, "duration": 4.561 }, { "text": "dictionary to be inside of another", "start": 3868.0, "duration": 4.799 }, { "text": "dictionary if the value of some key", "start": 3870.16, "duration": 5.04 }, { "text": "itself is another dictionary so this is", "start": 3872.799, "duration": 3.76 }, { "text": "a common paradigm and even though it", "start": 3875.2, "duration": 3.52 }, { "text": "might seem a bit cryptic it's just", "start": 3876.559, "duration": 4.0 }, { "text": "something that allows us to associate", "start": 3878.72, "duration": 4.319 }, { "text": "more keys with more values now most of", "start": 3880.559, "duration": 4.081 }, { "text": "this information i probably don't care", "start": 3883.039, "duration": 3.601 }, { "text": "about for instance according to apple", "start": 3884.64, "duration": 4.159 }, { "text": "the unique identifier for weezer is", "start": 3886.64, "duration": 4.28 }, { "text": "apparently 115", "start": 3888.799, "duration": 4.721 }, { "text": "234. that might be useful if i'm making", "start": 3890.92, "duration": 4.28 }, { "text": "my own database and i want this to be", "start": 3893.52, "duration": 4.0 }, { "text": "searchable but for today's purposes all", "start": 3895.2, "duration": 4.639 }, { "text": "i care about is the name of the track", "start": 3897.52, "duration": 5.2 }, { "text": "otherwise called track name as key and", "start": 3899.839, "duration": 4.96 }, { "text": "the first song and only song because we", "start": 3902.72, "duration": 4.319 }, { "text": "limited it to one that we got back from", "start": 3904.799, "duration": 4.32 }, { "text": "itunes here is the song that you might", "start": 3907.039, "duration": 5.04 }, { "text": "know by weezer called say it ain't so", "start": 3909.119, "duration": 5.92 }, { "text": "so now i have a bit of a clue if my goal", "start": 3912.079, "duration": 5.361 }, { "text": "here is to implement a program called", "start": 3915.039, "duration": 4.8 }, { "text": "itunes.pi that doesn't just dump the", "start": 3917.44, "duration": 3.76 }, { "text": "response from the server which is", "start": 3919.839, "duration": 3.681 }, { "text": "admittedly very cryptic but to print out", "start": 3921.2, "duration": 5.2 }, { "text": "all of the songs that itunes has for the", "start": 3923.52, "duration": 6.0 }, { "text": "band called weezer maybe i can iterate", "start": 3926.4, "duration": 5.439 }, { "text": "over this somehow so let me backtrack", "start": 3929.52, "duration": 4.559 }, { "text": "here's the key called track name", "start": 3931.839, "duration": 4.641 }, { "text": "it is inside of a dictionary", "start": 3934.079, "duration": 5.76 }, { "text": "that is the value of results here", "start": 3936.48, "duration": 5.599 }, { "text": "so how can i go about getting this well", "start": 3939.839, "duration": 4.321 }, { "text": "let me go ahead and try this let me go", "start": 3942.079, "duration": 4.081 }, { "text": "ahead and shrink my terminal window back", "start": 3944.16, "duration": 2.879 }, { "text": "down", "start": 3946.16, "duration": 2.8 }, { "text": "and let me propose now for one final", "start": 3947.039, "duration": 4.08 }, { "text": "flourish we don't just lazily print out", "start": 3948.96, "duration": 3.68 }, { "text": "the contents of that response because", "start": 3951.119, "duration": 3.041 }, { "text": "that's not interesting or pretty for", "start": 3952.64, "duration": 4.56 }, { "text": "anyone let's do this let me go ahead and", "start": 3954.16, "duration": 4.879 }, { "text": "create a new variable just for the sake", "start": 3957.2, "duration": 4.08 }, { "text": "of discussion called o for object and", "start": 3959.039, "duration": 4.241 }, { "text": "i'm going to go ahead and call", "start": 3961.28, "duration": 6.24 }, { "text": "o equals response dot json just to store", "start": 3963.28, "duration": 6.96 }, { "text": "that json response specifically in a", "start": 3967.52, "duration": 4.24 }, { "text": "variable called o but i could name it", "start": 3970.24, "duration": 3.44 }, { "text": "anything i want and now i'm going to do", "start": 3971.76, "duration": 2.88 }, { "text": "this", "start": 3973.68, "duration": 3.04 }, { "text": "for each result", "start": 3974.64, "duration": 2.88 }, { "text": "in", "start": 3976.72, "duration": 2.319 }, { "text": "that object's", "start": 3977.52, "duration": 2.48 }, { "text": "key", "start": 3979.039, "duration": 4.32 }, { "text": "called results go ahead and print out", "start": 3980.0, "duration": 6.72 }, { "text": "that results track name and notice i", "start": 3983.359, "duration": 4.881 }, { "text": "have used exactly the same", "start": 3986.72, "duration": 3.92 }, { "text": "capitalization track name has a capital", "start": 3988.24, "duration": 4.64 }, { "text": "n results is all lowercase and let me", "start": 3990.64, "duration": 4.56 }, { "text": "rewind before we run the actual program", "start": 3992.88, "duration": 4.8 }, { "text": "in line eight we are making an http", "start": 3995.2, "duration": 4.639 }, { "text": "request using python to the server just", "start": 3997.68, "duration": 4.0 }, { "text": "like you and i as humans type urls into", "start": 3999.839, "duration": 3.681 }, { "text": "a browser and hit enter this is the", "start": 4001.68, "duration": 3.76 }, { "text": "python equivalent thereof", "start": 4003.52, "duration": 4.96 }, { "text": "i am then on line 10 just grabbing from", "start": 4005.44, "duration": 4.879 }, { "text": "that variable that contains the server's", "start": 4008.48, "duration": 4.879 }, { "text": "response the json object that i care", "start": 4010.319, "duration": 4.641 }, { "text": "about the thing between those curly", "start": 4013.359, "duration": 4.401 }, { "text": "braces at the very top and the bottom", "start": 4014.96, "duration": 4.639 }, { "text": "but because we've poked around and", "start": 4017.76, "duration": 4.079 }, { "text": "because i read the documentation earlier", "start": 4019.599, "duration": 5.44 }, { "text": "i know that that object has a key called", "start": 4021.839, "duration": 5.601 }, { "text": "results and that results key again is a", "start": 4025.039, "duration": 4.08 }, { "text": "list now at the moment that list", "start": 4027.44, "duration": 4.56 }, { "text": "contains only one song say it ain't so", "start": 4029.119, "duration": 5.361 }, { "text": "because i limited my response to one but", "start": 4032.0, "duration": 4.16 }, { "text": "even so my loop will work it's just", "start": 4034.48, "duration": 3.28 }, { "text": "going to iterate once and each time", "start": 4036.16, "duration": 2.8 }, { "text": "through that loop it's going to print", "start": 4037.76, "duration": 3.039 }, { "text": "the current results", "start": 4038.96, "duration": 3.119 }, { "text": "track name", "start": 4040.799, "duration": 2.56 }, { "text": "if i want to make this even more", "start": 4042.079, "duration": 3.121 }, { "text": "interesting let me change this limit now", "start": 4043.359, "duration": 4.0 }, { "text": "from 1 to 50 so i'll at least get back", "start": 4045.2, "duration": 5.04 }, { "text": "50 track names instead let me go ahead", "start": 4047.359, "duration": 4.641 }, { "text": "now and increase the size of my terminal", "start": 4050.24, "duration": 3.92 }, { "text": "once more and go ahead now and run", "start": 4052.0, "duration": 4.72 }, { "text": "python of itunes dot pi searching again", "start": 4054.16, "duration": 5.76 }, { "text": "for band like weezer and here we go", "start": 4056.72, "duration": 6.879 }, { "text": "and voila there are 50 songs that itunes", "start": 4059.92, "duration": 5.6 }, { "text": "has for weezer and if we scroll back up", "start": 4063.599, "duration": 5.041 }, { "text": "to the top here we'll see that the very", "start": 4065.52, "duration": 4.96 }, { "text": "first one there is indeed say it ain't", "start": 4068.64, "duration": 3.919 }, { "text": "so but now we got undone the sweater", "start": 4070.48, "duration": 4.319 }, { "text": "song buddy holly apparently another", "start": 4072.559, "duration": 3.921 }, { "text": "rendition of say it ain't so perhaps", "start": 4074.799, "duration": 3.76 }, { "text": "from another album another buddy holly", "start": 4076.48, "duration": 5.359 }, { "text": "undone my name is jonas and so forth", "start": 4078.559, "duration": 5.52 }, { "text": "questions now on this program which", "start": 4081.839, "duration": 4.801 }, { "text": "integrates python with a real-world", "start": 4084.079, "duration": 6.321 }, { "text": "third-party api", "start": 4086.64, "duration": 6.32 }, { "text": "yeah hi uh can we use break instead of", "start": 4090.4, "duration": 5.6 }, { "text": "system.exist exactly good question but", "start": 4092.96, "duration": 5.52 }, { "text": "no um break again is used to break out", "start": 4096.0, "duration": 5.04 }, { "text": "of things like loops like we saw earlier", "start": 4098.48, "duration": 4.799 }, { "text": "sys.exit is used to break out of the", "start": 4101.04, "duration": 5.199 }, { "text": "whole program itself use break for loops", "start": 4103.279, "duration": 4.88 }, { "text": "for now and use cis.exit to terminate", "start": 4106.239, "duration": 4.48 }, { "text": "the whole program good question", "start": 4108.159, "duration": 4.16 }, { "text": "other questions now on this program are", "start": 4110.719, "duration": 4.56 }, { "text": "others from where we bring the name of", "start": 4112.319, "duration": 4.641 }, { "text": "the key results", "start": 4115.279, "duration": 3.281 }, { "text": "from where do we get the name of the key", "start": 4116.96, "duration": 4.64 }, { "text": "uh results itself can we change the", "start": 4118.56, "duration": 4.239 }, { "text": "results", "start": 4121.6, "duration": 3.04 }, { "text": "you cannot you so we could in our", "start": 4122.799, "duration": 3.841 }, { "text": "program so the keys that come back in", "start": 4124.64, "duration": 4.0 }, { "text": "that json response to be clear come from", "start": 4126.64, "duration": 3.76 }, { "text": "itunes.apple.com", "start": 4128.64, "duration": 3.76 }, { "text": "some engineer some team of engineers", "start": 4130.4, "duration": 4.56 }, { "text": "decided for us what all of those keys", "start": 4132.4, "duration": 4.64 }, { "text": "would be called including track name", "start": 4134.96, "duration": 4.56 }, { "text": "results result count and everything else", "start": 4137.04, "duration": 4.639 }, { "text": "you and i can absolutely store those", "start": 4139.52, "duration": 4.08 }, { "text": "same values in variables just like i'm", "start": 4141.679, "duration": 3.841 }, { "text": "doing here with o just like i'm doing", "start": 4143.6, "duration": 3.84 }, { "text": "here with results you can rename those", "start": 4145.52, "duration": 3.6 }, { "text": "keys anything you want using python", "start": 4147.44, "duration": 4.319 }, { "text": "variables but the json response is", "start": 4149.12, "duration": 5.599 }, { "text": "coming from that third-party server", "start": 4151.759, "duration": 5.841 }, { "text": "other questions yes sir so i have a", "start": 4154.719, "duration": 6.161 }, { "text": "question related to cause a package", "start": 4157.6, "duration": 4.32 }, { "text": "so like", "start": 4160.88, "duration": 2.24 }, { "text": "uh yes", "start": 4161.92, "duration": 4.64 }, { "text": "so so what sort of uh ascii graphics uh", "start": 4163.12, "duration": 5.119 }, { "text": "is it capable of", "start": 4166.56, "duration": 4.639 }, { "text": "outputting the calce package um i would", "start": 4168.239, "duration": 4.801 }, { "text": "refer you to the url in the slides", "start": 4171.199, "duration": 4.241 }, { "text": "earlier uh if only because it's more", "start": 4173.04, "duration": 4.159 }, { "text": "thorough they have not just cows but", "start": 4175.44, "duration": 3.52 }, { "text": "tyrannosaurus rex's and several other", "start": 4177.199, "duration": 3.761 }, { "text": "animals as well i should emphasize that", "start": 4178.96, "duration": 3.52 }, { "text": "this is not a package i suspect you will", "start": 4180.96, "duration": 3.279 }, { "text": "use much in the real world it's really", "start": 4182.48, "duration": 3.679 }, { "text": "just meant to be representative of the", "start": 4184.239, "duration": 3.681 }, { "text": "types of packages you can install but", "start": 4186.159, "duration": 3.52 }, { "text": "allow me to refer to the documentation", "start": 4187.92, "duration": 4.64 }, { "text": "for what more is there but ascii art uh", "start": 4189.679, "duration": 4.961 }, { "text": "is the all we had before there were", "start": 4192.56, "duration": 4.32 }, { "text": "emojis let alone gifs and jpegs and", "start": 4194.64, "duration": 4.96 }, { "text": "pings but it's what is immortalized in", "start": 4196.88, "duration": 5.12 }, { "text": "cow say well allow me to transition us", "start": 4199.6, "duration": 5.36 }, { "text": "back now to one final capability of", "start": 4202.0, "duration": 5.76 }, { "text": "python which is that you yourselves have", "start": 4204.96, "duration": 5.52 }, { "text": "the ability to make your own libraries", "start": 4207.76, "duration": 5.28 }, { "text": "up until now we've been writing all of", "start": 4210.48, "duration": 5.36 }, { "text": "our functions in our one file hello pi", "start": 4213.04, "duration": 4.96 }, { "text": "and everything since and now that we've", "start": 4215.84, "duration": 5.839 }, { "text": "introduced modules in python like random", "start": 4218.0, "duration": 5.92 }, { "text": "and statistics we can import those that", "start": 4221.679, "duration": 3.681 }, { "text": "come with python but that's other", "start": 4223.92, "duration": 3.52 }, { "text": "people's code as well and we've now used", "start": 4225.36, "duration": 3.839 }, { "text": "pip this package manager to install", "start": 4227.44, "duration": 3.6 }, { "text": "third-party packages as well in the", "start": 4229.199, "duration": 3.601 }, { "text": "system and using other people's code", "start": 4231.04, "duration": 2.639 }, { "text": "still", "start": 4232.8, "duration": 2.879 }, { "text": "but to come full circle what if you", "start": 4233.679, "duration": 4.0 }, { "text": "yourself find yourself implementing the", "start": 4235.679, "duration": 4.56 }, { "text": "same kinds of functions again and again", "start": 4237.679, "duration": 4.401 }, { "text": "or you find yourself opening up old", "start": 4240.239, "duration": 3.92 }, { "text": "programs copying and pasting code you", "start": 4242.08, "duration": 4.079 }, { "text": "wrote into new programs because you have", "start": 4244.159, "duration": 4.161 }, { "text": "the same problem yet again a good", "start": 4246.159, "duration": 4.881 }, { "text": "practice would be to somehow bundle up", "start": 4248.32, "duration": 5.28 }, { "text": "that code you keep reusing and make your", "start": 4251.04, "duration": 5.04 }, { "text": "own python module or package you can", "start": 4253.6, "duration": 4.48 }, { "text": "keep it local on your own mac or pc or", "start": 4256.08, "duration": 4.48 }, { "text": "cloud server or you can go through the", "start": 4258.08, "duration": 4.32 }, { "text": "steps of actually bundling it up making", "start": 4260.56, "duration": 3.599 }, { "text": "it free in open source and putting it on", "start": 4262.4, "duration": 4.319 }, { "text": "something like pi pi for others to use", "start": 4264.159, "duration": 4.481 }, { "text": "as well okay i'm going to go ahead and", "start": 4266.719, "duration": 4.48 }, { "text": "run code of sayings.pi to create a brand", "start": 4268.64, "duration": 4.32 }, { "text": "new file called sayings.pi which is", "start": 4271.199, "duration": 4.241 }, { "text": "going to be my own sayings module i'm", "start": 4272.96, "duration": 3.92 }, { "text": "going to define a couple of simple", "start": 4275.44, "duration": 3.12 }, { "text": "functions in there i'm going to define a", "start": 4276.88, "duration": 3.52 }, { "text": "hello function that's going to take a", "start": 4278.56, "duration": 4.0 }, { "text": "name parameter as input and that", "start": 4280.4, "duration": 4.64 }, { "text": "function is simply going to print out an", "start": 4282.56, "duration": 4.96 }, { "text": "f string that contains hello comma and", "start": 4285.04, "duration": 4.08 }, { "text": "then in curly braces whatever that", "start": 4287.52, "duration": 3.84 }, { "text": "person's name actually is", "start": 4289.12, "duration": 3.52 }, { "text": "then i'm going to go ahead and define", "start": 4291.36, "duration": 3.44 }, { "text": "one other function a goodbye function", "start": 4292.64, "duration": 5.36 }, { "text": "that has def goodbye also takes a name", "start": 4294.8, "duration": 5.439 }, { "text": "as its input and then that prints out by", "start": 4298.0, "duration": 4.719 }, { "text": "contrast an f string that says goodbye", "start": 4300.239, "duration": 5.601 }, { "text": "comma and then in curly braces name and", "start": 4302.719, "duration": 5.281 }, { "text": "now just for good measure just so i can", "start": 4305.84, "duration": 3.92 }, { "text": "be sure that these functions are working", "start": 4308.0, "duration": 3.04 }, { "text": "as expected i'm going to go ahead and", "start": 4309.76, "duration": 3.6 }, { "text": "define a main function in here too just", "start": 4311.04, "duration": 4.0 }, { "text": "for the purposes of testing and i'm", "start": 4313.36, "duration": 2.96 }, { "text": "going to go ahead and define a main", "start": 4315.04, "duration": 4.0 }, { "text": "function that simply does a couple of", "start": 4316.32, "duration": 6.64 }, { "text": "tests for instance it calls uh hello of", "start": 4319.04, "duration": 6.32 }, { "text": "quote-unquote worlds shall we say and", "start": 4322.96, "duration": 4.64 }, { "text": "then it's going to call goodbye of quote", "start": 4325.36, "duration": 4.56 }, { "text": "unquote world as well and hopefully what", "start": 4327.6, "duration": 3.599 }, { "text": "i'll see on the screen then is hello", "start": 4329.92, "duration": 3.12 }, { "text": "world and goodbye world when i run this", "start": 4331.199, "duration": 3.761 }, { "text": "program of course as always i need to", "start": 4333.04, "duration": 3.84 }, { "text": "explicitly tell python to call that", "start": 4334.96, "duration": 3.6 }, { "text": "function so i'm going to call main at", "start": 4336.88, "duration": 3.44 }, { "text": "the very bottom of this file all right", "start": 4338.56, "duration": 4.96 }, { "text": "let's try it out python of sayings.pie", "start": 4340.32, "duration": 5.44 }, { "text": "enter and indeed i see hello world and", "start": 4343.52, "duration": 3.76 }, { "text": "goodbye world and so i think it's", "start": 4345.76, "duration": 3.28 }, { "text": "reasonable for me to assume that these", "start": 4347.28, "duration": 3.919 }, { "text": "functions albeit simple are pretty", "start": 4349.04, "duration": 4.32 }, { "text": "correct at this point but now suppose", "start": 4351.199, "duration": 4.0 }, { "text": "that i want to use these functions as", "start": 4353.36, "duration": 3.44 }, { "text": "though i've indeed created my own", "start": 4355.199, "duration": 4.48 }, { "text": "library my own python module that makes", "start": 4356.8, "duration": 4.72 }, { "text": "available a hello function for me or", "start": 4359.679, "duration": 3.52 }, { "text": "anyone else who wants to use it or a", "start": 4361.52, "duration": 3.84 }, { "text": "goodbye function as well well let me go", "start": 4363.199, "duration": 5.281 }, { "text": "ahead and open up again say.pi but start", "start": 4365.36, "duration": 5.28 }, { "text": "fresh and rather than have the cow say", "start": 4368.48, "duration": 4.96 }, { "text": "anything let me go ahead and have my own", "start": 4370.64, "duration": 5.2 }, { "text": "library do the talking so i'm going to", "start": 4373.44, "duration": 4.88 }, { "text": "go ahead and as before import sys so", "start": 4375.84, "duration": 3.92 }, { "text": "that i have access to command line", "start": 4378.32, "duration": 4.32 }, { "text": "arguments and from my own module called", "start": 4379.76, "duration": 5.439 }, { "text": "sayings i'm going to import hello so", "start": 4382.64, "duration": 4.24 }, { "text": "because i created a file called", "start": 4385.199, "duration": 3.281 }, { "text": "sayings.pi", "start": 4386.88, "duration": 4.16 }, { "text": "i can say from sayings and it's inferred", "start": 4388.48, "duration": 4.56 }, { "text": "by python that i mean sayings.pi at", "start": 4391.04, "duration": 3.679 }, { "text": "least in this current directory but i", "start": 4393.04, "duration": 3.52 }, { "text": "specifically going to import just one of", "start": 4394.719, "duration": 4.321 }, { "text": "the functions for now namely hello and", "start": 4396.56, "duration": 4.32 }, { "text": "now i can do something like this if the", "start": 4399.04, "duration": 4.24 }, { "text": "user obliges by giving me two command", "start": 4400.88, "duration": 4.4 }, { "text": "line arguments which i can check by just", "start": 4403.28, "duration": 4.56 }, { "text": "checking the length of sys.org v i'm", "start": 4405.28, "duration": 4.879 }, { "text": "going to then go ahead and call this new", "start": 4407.84, "duration": 4.92 }, { "text": "hello function passing is its input", "start": 4410.159, "duration": 4.881 }, { "text": "assist.rgv bracket1 which should", "start": 4412.76, "duration": 3.88 }, { "text": "hopefully be the person's name which i'm", "start": 4415.04, "duration": 2.96 }, { "text": "going to expect them to type at the", "start": 4416.64, "duration": 3.28 }, { "text": "prompt so here we go i'm going to go", "start": 4418.0, "duration": 4.159 }, { "text": "down to my terminal window run python of", "start": 4419.92, "duration": 5.44 }, { "text": "say.pi and my own name because i want my", "start": 4422.159, "duration": 4.56 }, { "text": "own name to end up in the command line", "start": 4425.36, "duration": 3.04 }, { "text": "arguments and therefore be part of the", "start": 4426.719, "duration": 3.601 }, { "text": "hello so when i hit enter in just a", "start": 4428.4, "duration": 4.0 }, { "text": "moment i should hopefully see hello", "start": 4430.32, "duration": 5.28 }, { "text": "comma david so here we go enter", "start": 4432.4, "duration": 6.48 }, { "text": "and huh i see hello world goodbye world", "start": 4435.6, "duration": 6.72 }, { "text": "and then i see hello david so", "start": 4438.88, "duration": 6.24 }, { "text": "why is this happening well it turns out", "start": 4442.32, "duration": 4.0 }, { "text": "even though i've done everything", "start": 4445.12, "duration": 4.48 }, { "text": "according to our own past practice it's", "start": 4446.32, "duration": 5.76 }, { "text": "not really the right way to go about", "start": 4449.6, "duration": 5.04 }, { "text": "calling maine after all if i'm blindly", "start": 4452.08, "duration": 4.24 }, { "text": "calling main here at the bottom of my", "start": 4454.64, "duration": 3.12 }, { "text": "file that means whenever this file is", "start": 4456.32, "duration": 3.52 }, { "text": "loaded by python main is going to get", "start": 4457.76, "duration": 4.64 }, { "text": "called and unfortunately that's true", "start": 4459.84, "duration": 5.04 }, { "text": "even if i'm importing this file or just", "start": 4462.4, "duration": 4.64 }, { "text": "a function from this file as i am here", "start": 4464.88, "duration": 4.799 }, { "text": "in my say.pi program this is to say on", "start": 4467.04, "duration": 5.199 }, { "text": "mine three here when i say from sayings", "start": 4469.679, "duration": 4.641 }, { "text": "import hello this effectively tells", "start": 4472.239, "duration": 4.881 }, { "text": "python to go find that module sayings.pi", "start": 4474.32, "duration": 4.8 }, { "text": "read it from top to bottom left to right", "start": 4477.12, "duration": 3.76 }, { "text": "and then import specifically the hello", "start": 4479.12, "duration": 3.76 }, { "text": "function unfortunately by the time", "start": 4480.88, "duration": 3.76 }, { "text": "python has read the file from top to", "start": 4482.88, "duration": 4.24 }, { "text": "bottom left to right that last line of", "start": 4484.64, "duration": 5.039 }, { "text": "code recall is to call main main gets", "start": 4487.12, "duration": 5.2 }, { "text": "called no matter what so really the", "start": 4489.679, "duration": 4.961 }, { "text": "right way to go about using a main", "start": 4492.32, "duration": 4.16 }, { "text": "function which does solve that problem", "start": 4494.64, "duration": 3.36 }, { "text": "of ensuring that we can order our", "start": 4496.48, "duration": 3.28 }, { "text": "functions however we want and all the", "start": 4498.0, "duration": 3.6 }, { "text": "functions will be defined at the time", "start": 4499.76, "duration": 3.72 }, { "text": "they're invoked i shouldn't be", "start": 4501.6, "duration": 3.76 }, { "text": "unconditionally calling main at the", "start": 4503.48, "duration": 3.64 }, { "text": "bottom of this or really any of my", "start": 4505.36, "duration": 3.76 }, { "text": "programs i should instead use this", "start": 4507.12, "duration": 4.64 }, { "text": "technique i should say if underscore", "start": 4509.12, "duration": 5.039 }, { "text": "underscore name underscore underscore", "start": 4511.76, "duration": 4.8 }, { "text": "equals equals quote unquote underscore", "start": 4514.159, "duration": 4.881 }, { "text": "underscore main underscore underscore", "start": 4516.56, "duration": 5.2 }, { "text": "close quote then and only then should", "start": 4519.04, "duration": 5.52 }, { "text": "you actually call main well it turns out", "start": 4521.76, "duration": 4.64 }, { "text": "that this variable is a special symbol", "start": 4524.56, "duration": 4.159 }, { "text": "in python underscore underscore name", "start": 4526.4, "duration": 4.48 }, { "text": "underscore underscore and notice that vs", "start": 4528.719, "duration": 3.921 }, { "text": "code because of its font isn't quite", "start": 4530.88, "duration": 3.2 }, { "text": "showing those two underscores but", "start": 4532.64, "duration": 2.88 }, { "text": "they're indeed there to the left and the", "start": 4534.08, "duration": 3.28 }, { "text": "right this is a special variable whose", "start": 4535.52, "duration": 4.159 }, { "text": "value is automatically set by python to", "start": 4537.36, "duration": 4.48 }, { "text": "be quote unquote main", "start": 4539.679, "duration": 4.881 }, { "text": "when you run a file from the command", "start": 4541.84, "duration": 6.24 }, { "text": "line as by running python of sayings.pi", "start": 4544.56, "duration": 5.44 }, { "text": "so watch what happens now with this", "start": 4548.08, "duration": 4.8 }, { "text": "additional conditional in sayings.pi if", "start": 4550.0, "duration": 5.6 }, { "text": "i run python of sayings.hi it still", "start": 4552.88, "duration": 6.4 }, { "text": "works as before because name will be", "start": 4555.6, "duration": 6.16 }, { "text": "automatically set to underscore", "start": 4559.28, "duration": 4.56 }, { "text": "underscore main underscore underscore", "start": 4561.76, "duration": 4.72 }, { "text": "when i run this file using python of", "start": 4563.84, "duration": 5.359 }, { "text": "sayings.pi but notice this", "start": 4566.48, "duration": 4.96 }, { "text": "name is not going to be set to quote", "start": 4569.199, "duration": 3.761 }, { "text": "unquote main it's going to be set to", "start": 4571.44, "duration": 2.799 }, { "text": "something else technically the name of", "start": 4572.96, "duration": 3.68 }, { "text": "the module when i instead import the", "start": 4574.239, "duration": 4.721 }, { "text": "file like i do here", "start": 4576.64, "duration": 4.0 }, { "text": "so this highlighted line of code even", "start": 4578.96, "duration": 3.52 }, { "text": "though it will cause python to go find", "start": 4580.64, "duration": 4.0 }, { "text": "sayings.pi read it from top to bottom", "start": 4582.48, "duration": 4.32 }, { "text": "left to right it's going to ignore the", "start": 4584.64, "duration": 3.68 }, { "text": "call to main this time because it's", "start": 4586.8, "duration": 3.439 }, { "text": "wrapped in that conditional in this case", "start": 4588.32, "duration": 4.399 }, { "text": "when i'm importing a file and not", "start": 4590.239, "duration": 4.48 }, { "text": "running it directly at the command line", "start": 4592.719, "duration": 4.401 }, { "text": "main will not get called by definition", "start": 4594.719, "duration": 4.641 }, { "text": "of that names value so let me go ahead", "start": 4597.12, "duration": 4.16 }, { "text": "and try this instead of running python", "start": 4599.36, "duration": 4.319 }, { "text": "of sayings.pi which is the module which", "start": 4601.28, "duration": 4.56 }, { "text": "contains that conditional main let me go", "start": 4603.679, "duration": 5.361 }, { "text": "ahead here on run python of say.pi which", "start": 4605.84, "duration": 5.52 }, { "text": "is the program here before me that", "start": 4609.04, "duration": 5.6 }, { "text": "imports hello from sayings but because", "start": 4611.36, "duration": 4.56 }, { "text": "of that conditional it's not going to", "start": 4614.64, "duration": 4.16 }, { "text": "say hello to anyone else except", "start": 4615.92, "duration": 4.88 }, { "text": "me in this case", "start": 4618.8, "duration": 3.6 }, { "text": "all right we're here at the end of our", "start": 4620.8, "duration": 3.28 }, { "text": "week it's only appropriate i think to", "start": 4622.4, "duration": 3.52 }, { "text": "import something other than hello why", "start": 4624.08, "duration": 3.68 }, { "text": "don't i go ahead and import not hello", "start": 4625.92, "duration": 4.319 }, { "text": "but goodbye from here let me go ahead", "start": 4627.76, "duration": 4.8 }, { "text": "and call goodbye instead of hello and", "start": 4630.239, "duration": 4.561 }, { "text": "this time when i run python of say pi", "start": 4632.56, "duration": 3.92 }, { "text": "i'm not going to type my own name allow", "start": 4634.8, "duration": 3.68 }, { "text": "me if i may to type in the whole world", "start": 4636.48, "duration": 4.4 }, { "text": "so that our final sentiment today is", "start": 4638.48, "duration": 4.8 }, { "text": "goodbye world indeed that's it for this", "start": 4640.88, "duration": 6.92 }, { "text": "week we will see you next time", "start": 4643.28, "duration": 4.52 } ]