title
Python - Intro to Computer Science - Harvard's CS50 (2018)
description
Learn the basics of the Python programming language.
This course teaches the foundations of computer science. This video is lecture 6 of Harvard University's CS50 2018 course (part 7 since the lectures start at 0).
Check out our full CS50 playlist: https://www.youtube.com/playlist?list=PLWKjhJtqVAbmGw5fN5BQlwuug-8bDmabi
🔗CS50 IDE (must have free edX account): https://cs50.io/
🔗Notes: https://cs50.harvard.edu/x/2020/notes/6/
🔗Problem Set: https://cs50.harvard.edu/x/2020/psets/6/
🔗Source Code: https://cdn.cs50.net/2019/fall/lectures/6/src6.zip
⭐️Contents⭐️
⌨️ (0:00:00) Introduction
⌨️ (0:00:50) Week 5 Recap
⌨️ (0:13:01) resize.py
⌨️ (0:16:52) Python Syntax
⌨️ (0:23:48) Interpreting vs. Compiling
⌨️ (0:26:52) hello.py
⌨️ (0:29:54) string0.py
⌨️ (0:33:02) string1.py
⌨️ (0:35:00) ints.py
⌨️ (0:38:26) floats.dpy
⌨️ (0:42:58) overflow.py
⌨️ (0:46:26) conditions.py
⌨️ (0:48:53) answer.py
⌨️ (0:50:57) cough0.py
⌨️ (0:51:40) cough1.py
⌨️ (0:52:19) cough2.py
⌨️ (0:57:01) cough3.py
⌨️ (1:01:26) positive.py
⌨️ (1:06:51) capitalize2.py
⌨️ (1:11:46) strlen.py
⌨️ (1:15:51) argv0.py
⌨️ (1:18:39) argv1.py
⌨️ (1:20:26) swap.py
⌨️ (1:22:58) list.py
⌨️ (1:27:22) struct0.py
⌨️ (1:32:38) mario0.py
⌨️ (1:33:28) mario1.py
⌨️ (1:34:45) mario2.py
⌨️ (1:35:22) mario3.py
⌨️ (1:37:57) resize.py, continued
⌨️ (1:42:36) dictionary.py
Lecture taught by David J. Malan. Thanks to Harvard's CS50 for giving us permission to post this lecture. Checkout their YouTube channel for more great lectures: https://www.youtube.com/cs50
--
Learn to code for free and get a developer job: https://www.freecodecamp.org
Read hundreds of articles on programming: https://medium.freecodecamp.org
detail
{'title': "Python - Intro to Computer Science - Harvard's CS50 (2018)", 'heatmap': [{'end': 2431.887, 'start': 2354.282, 'weight': 0.992}, {'end': 5921.349, 'start': 5849.848, 'weight': 1}], 'summary': 'Covers a range of topics including web protocols, http basics, python syntax and differences from c, python programming features, user input, strings, arrays, python 3 documentation, functions, data structures, image processing, and performance comparison between c and python, demonstrating practical examples and quantifiable data like server response codes, programming languages, and spell check program performance.', 'chapters': [{'end': 336.346, 'segs': [{'end': 79.663, 'src': 'embed', 'start': 50.498, 'weight': 1, 'content': [{'end': 53.739, 'text': 'This is CS50, and this is lecture six.', 'start': 50.498, 'duration': 3.241}, {'end': 59.039, 'text': 'And you recall that last week we introduced web programming by way of HTML and CSS, or at least the building blocks,', 'start': 53.779, 'duration': 5.26}, {'end': 61.22, 'text': "because we don't actually have the ability to program yet.", 'start': 59.039, 'duration': 2.181}, {'end': 61.98, 'text': "It's just markup.", 'start': 61.26, 'duration': 0.72}, {'end': 64.519, 'text': 'HTML and CSS was stylization thereof.', 'start': 62.38, 'duration': 2.139}, {'end': 70.441, 'text': 'But we introduced this metaphor last week of a protocol called TCPIP, and we related it to, of course, an envelope.', 'start': 64.78, 'duration': 5.661}, {'end': 74.622, 'text': 'And on this envelope virtually on the front was at least two pieces of information.', 'start': 70.962, 'duration': 3.66}, {'end': 79.663, 'text': 'And if anyone remembers, what were those two pieces of information in the to field? DAVID J.', 'start': 74.842, 'duration': 4.821}], 'summary': 'Cs50 lecture six introduces web programming and tcpip protocol with html and css.', 'duration': 29.165, 'max_score': 50.498, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU50498.jpg'}, {'end': 132.021, 'src': 'embed', 'start': 87.986, 'weight': 0, 'content': [{'end': 89.607, 'text': 'And one other thing, if you remember.', 'start': 87.986, 'duration': 1.621}, {'end': 92.548, 'text': 'Oh, come on.', 'start': 92.168, 'duration': 0.38}, {'end': 93.909, 'text': 'It was like two minutes ago.', 'start': 92.568, 'duration': 1.341}, {'end': 103.297, 'text': "OK, A port number, so another number, shorter number, that's just a number like 80 or 443, referring to HTTP or HTTPS,", 'start': 94.009, 'duration': 9.288}, {'end': 105.58, 'text': 'or other numbers like 25 for email and the like.', 'start': 103.297, 'duration': 2.283}, {'end': 111.729, 'text': 'And so together, these unique addresses allow you to send information to not only a specific computer, but a specific service.', 'start': 105.78, 'duration': 5.949}, {'end': 113.29, 'text': 'running on that computer.', 'start': 112.009, 'duration': 1.281}, {'end': 121.215, 'text': "And in order to actually request information from that server, there's this other protocol called HTTP, hypertext transfer protocol.", 'start': 113.85, 'duration': 7.365}, {'end': 123.656, 'text': "This is what's inside of the envelope.", 'start': 121.455, 'duration': 2.201}, {'end': 127.058, 'text': 'So, when the server opens it up, metaphorically looks inside.', 'start': 123.676, 'duration': 3.382}, {'end': 132.021, 'text': 'this is the command that that server reads in order to decide what it should actually respond with.', 'start': 127.058, 'duration': 4.963}], 'summary': 'Port numbers like 80, 443, and 25 allow specific service communication on a computer, with http as the protocol for requesting information.', 'duration': 44.035, 'max_score': 87.986, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU87986.jpg'}, {'end': 236.617, 'src': 'embed', 'start': 209.656, 'weight': 5, 'content': [{'end': 212.738, 'text': "So the question mark just says that's it for the file name or the URL.", 'start': 209.656, 'duration': 3.082}, {'end': 214.219, 'text': "Here comes the user's input.", 'start': 212.798, 'duration': 1.421}, {'end': 220.504, 'text': 'Q is just literally the HTTP parameter or input that Larry and Sergey, founders of Google,', 'start': 214.52, 'duration': 5.984}, {'end': 223.927, 'text': "20 years ago decided would represent the user's input Q for query.", 'start': 220.504, 'duration': 3.423}, {'end': 227.27, 'text': 'Equal just means the query that the human typed in was cat.', 'start': 224.367, 'duration': 2.903}, {'end': 229.171, 'text': "But the human doesn't even have to type this in.", 'start': 227.59, 'duration': 1.581}, {'end': 231.033, 'text': 'Once you understand HTTP.', 'start': 229.251, 'duration': 1.782}, {'end': 235.516, 'text': 'if you really wanted to be kind of a nerd, you could go to www.google.com.', 'start': 231.033, 'duration': 4.483}, {'end': 236.617, 'text': 'slash search.', 'start': 235.516, 'duration': 1.101}], 'summary': "20 years ago, founders of google chose 'q' to represent user input for query, equal to 'cat'", 'duration': 26.961, 'max_score': 209.656, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU209656.jpg'}, {'end': 296.351, 'src': 'embed', 'start': 249.79, 'weight': 4, 'content': [{'end': 253.634, 'text': 'Now, the server hopefully responds with a message you never, ever actually see.', 'start': 249.79, 'duration': 3.844}, {'end': 256.738, 'text': 'HTTP 200, which literally means OK.', 'start': 253.935, 'duration': 2.803}, {'end': 265.312, 'text': 'Of course, many of us have seen numbers other than 200 appear, like what? 404, which means? File not found.', 'start': 257.038, 'duration': 8.274}, {'end': 272.937, 'text': 'Now, why humans decided years ago to tell other humans what that numeric code is, I mean, that is an uninteresting detail.', 'start': 265.332, 'duration': 7.605}, {'end': 276.639, 'text': 'But the world, for whatever reason, has revealed in many websites 404.', 'start': 272.977, 'duration': 3.662}, {'end': 278.02, 'text': 'But it just means the same thing.', 'start': 276.639, 'duration': 1.381}, {'end': 279.141, 'text': 'Everything is not OK.', 'start': 278.08, 'duration': 1.061}, {'end': 280.562, 'text': 'A file was not found.', 'start': 279.461, 'duration': 1.101}, {'end': 282.143, 'text': 'You might see something else like this.', 'start': 280.882, 'duration': 1.261}, {'end': 286.226, 'text': 'We saw this with Harvard, in fact, curiously, that Harvard had moved permanently.', 'start': 282.223, 'duration': 4.003}, {'end': 296.351, 'text': 'Now, Harvard was responding to certain queries with HTTP 301s in order to achieve what feature or effect? What? Yeah.', 'start': 286.686, 'duration': 9.665}], 'summary': 'Http codes like 200 and 404 indicate server responses; harvard used http 301 for certain queries.', 'duration': 46.561, 'max_score': 249.79, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU249790.jpg'}], 'start': 50.498, 'title': 'Web protocols and http basics', 'summary': 'Covers tcp/ip protocol, ip addresses, and port numbers in web programming, http protocol, default file name, server response codes (200, 404, 301), and http parameters in web queries.', 'chapters': [{'end': 154.537, 'start': 50.498, 'title': 'Cs50 lecture 6: web programming and protocols', 'summary': 'Introduces the tcp/ip protocol and its relation to web programming, highlighting the use of ip addresses and port numbers to send information to specific services, and the http protocol for requesting and responding with web pages.', 'duration': 104.039, 'highlights': ['The lecture introduces the TCP/IP protocol and its relation to web programming, emphasizing the use of IP addresses and port numbers to send information to specific services.', 'It explains the HTTP protocol as the command inside the envelope, used by the server to determine its response to a request for information.', 'The use of numeric IP addresses and port numbers, like 80 or 443 for HTTP or HTTPS, is highlighted as unique identifiers for computers and services.', "The concept of requesting specific web pages using the HTTP protocol is discussed, emphasizing the server's role in responding to such requests."]}, {'end': 336.346, 'start': 154.537, 'title': 'Http basics and server response codes', 'summary': 'Explains the default file name on a web server, http parameters, server response codes, and url redirection, highlighting the significance of index.html, http 200, 404, and 301 response codes, and the purpose of http parameters in web queries.', 'duration': 181.809, 'highlights': ["The default file name on a server for a web page is 'index.html', and the server response code 'HTTP 200' indicates 'OK'.", "The '404' server response code signifies 'File not found', and '301' indicates 'Moved permanently', used for URL redirection.", "HTTP parameters like 'q' in the URL represent user input, and the purpose of HTTP is to automate the process of generating HTTP messages for web forms."]}], 'duration': 285.848, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU50498.jpg', 'highlights': ['The use of numeric IP addresses and port numbers, like 80 or 443 for HTTP or HTTPS, is highlighted as unique identifiers for computers and services.', 'The lecture introduces the TCP/IP protocol and its relation to web programming, emphasizing the use of IP addresses and port numbers to send information to specific services.', "The concept of requesting specific web pages using the HTTP protocol is discussed, emphasizing the server's role in responding to such requests.", 'The HTTP protocol as the command inside the envelope, used by the server to determine its response to a request for information.', "The default file name on a server for a web page is 'index.html', and the server response code 'HTTP 200' indicates 'OK'.", "HTTP parameters like 'q' in the URL represent user input, and the purpose of HTTP is to automate the process of generating HTTP messages for web forms.", "The '404' server response code signifies 'File not found', and '301' indicates 'Moved permanently', used for URL redirection."]}, {'end': 1357.242, 'segs': [{'end': 368.137, 'src': 'embed', 'start': 336.626, 'weight': 2, 'content': [{'end': 342.488, 'text': "Sometimes a website might prepend the www if you haven't typed it in, or you can be redirected most anywhere.", 'start': 336.626, 'duration': 5.862}, {'end': 347.85, 'text': "In fact, if you go to CS50's own website by just typing cs50.harvard.edu, watch the URL.", 'start': 342.508, 'duration': 5.342}, {'end': 351.971, 'text': "You'll be redirected to a more specific page depending on the time of year.", 'start': 347.87, 'duration': 4.101}, {'end': 353.512, 'text': 'So we use these tricks as well.', 'start': 352.031, 'duration': 1.481}, {'end': 355.453, 'text': '404 not found might look like this.', 'start': 353.992, 'duration': 1.461}, {'end': 360.474, 'text': 'But inside deeper, that metaphorical envelope, is the actual contents of the web page.', 'start': 355.713, 'duration': 4.761}, {'end': 368.137, 'text': "So you get back not only these HTTP headers, as they're called in the top of the response, so to speak, but you also get back HTML,", 'start': 360.514, 'duration': 7.623}], 'summary': "Websites can redirect users, like cs50's to specific pages. 404 error may hide actual content.", 'duration': 31.511, 'max_score': 336.626, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU336626.jpg'}, {'end': 431.056, 'src': 'embed', 'start': 402.914, 'weight': 1, 'content': [{'end': 409.04, 'text': 'because it really lets you control font size and positioning and lower level stuff that you might have started tinkering with with the most recent problem set.', 'start': 402.914, 'duration': 6.126}, {'end': 415.345, 'text': "Now we proposed that you probably shouldn't just start typing CSS inside of your HTML page,", 'start': 409.3, 'duration': 6.045}, {'end': 418.447, 'text': "because it's just a little harder to maintain as your examples get more sophisticated.", 'start': 415.345, 'duration': 3.102}, {'end': 419.708, 'text': 'So you might factor it out.', 'start': 418.707, 'duration': 1.001}, {'end': 426.232, 'text': 'And odds are, you did this for the problem set, because when making a home page, if you have the same CSS styles across multiple files,', 'start': 419.968, 'duration': 6.264}, {'end': 431.056, 'text': 'it would be pretty silly and inefficient to copy and paste them again and again when you can factor them out like this.', 'start': 426.232, 'duration': 4.824}], 'summary': 'Css allows control of font size, positioning, and maintenance efficiency.', 'duration': 28.142, 'max_score': 402.914, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU402914.jpg'}, {'end': 479.05, 'src': 'embed', 'start': 453.012, 'weight': 0, 'content': [{'end': 460.436, 'text': 'Thinking back a couple of weeks to our discussion of data structures, and each of these nodes in the tree we saw in JavaScript can be manipulated.', 'start': 453.012, 'duration': 7.424}, {'end': 462.677, 'text': 'And via that very simple principle,', 'start': 460.596, 'duration': 2.081}, {'end': 473.503, 'text': "writing code that modifies this existing tree in the browser's memory means you can make much more dynamic things like Gmail and Facebook and any number of websites that are constantly changing.", 'start': 462.677, 'duration': 10.826}, {'end': 475.425, 'text': 'You did not do this yet for the problem set.', 'start': 473.763, 'duration': 1.662}, {'end': 479.05, 'text': 'You made static web pages just by hard coding HTML and CSS.', 'start': 475.445, 'duration': 3.605}], 'summary': 'Manipulating tree nodes in javascript enables dynamic web content like gmail and facebook.', 'duration': 26.038, 'max_score': 453.012, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU453012.jpg'}, {'end': 615.775, 'src': 'embed', 'start': 592.744, 'weight': 3, 'content': [{'end': 600.111, 'text': "Let's do the same thing briefly with Python, but then spend more time at the keyboard comparing the two to see what actually is different about these.", 'start': 592.744, 'duration': 7.367}, {'end': 608.693, 'text': 'So why yet another language, though, first? We have Scratch, C, JavaScript, Python, not to mention HTML and CSS for different purposes.', 'start': 600.411, 'duration': 8.282}, {'end': 615.775, 'text': "Why do we have all of these darn languages already? Why didn't the humans just decide that's it? We're all using Scratch.", 'start': 609.133, 'duration': 6.642}], 'summary': 'Comparing python and other languages for efficiency and effectiveness.', 'duration': 23.031, 'max_score': 592.744, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU592744.jpg'}, {'end': 915.696, 'src': 'embed', 'start': 887.799, 'weight': 5, 'content': [{'end': 892.902, 'text': 'And it turns out in Python, You know what, I can actually use a library code that other people have written.', 'start': 887.799, 'duration': 5.103}, {'end': 896.524, 'text': 'Let me come up with a variable called in image, like in file.', 'start': 893.282, 'duration': 3.242}, {'end': 897.805, 'text': 'This is my input image.', 'start': 896.564, 'duration': 1.241}, {'end': 902.888, 'text': "And that's going to equal image.open, because I want to open this thing called in file.", 'start': 898.265, 'duration': 4.623}, {'end': 909.372, 'text': 'And then the width, let me get the width and the height of the existing image by doing input image.size.', 'start': 902.908, 'duration': 6.464}, {'end': 915.696, 'text': "And then let me go ahead and make a new image out image I'll call it which is going to equal the input image,", 'start': 909.812, 'duration': 5.884}], 'summary': 'Using python, a library code is used to open and manipulate image files.', 'duration': 27.897, 'max_score': 887.799, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU887799.jpg'}, {'end': 1084.45, 'src': 'embed', 'start': 1055.04, 'weight': 4, 'content': [{'end': 1057.261, 'text': 'let me have this variable called counter.', 'start': 1055.04, 'duration': 2.221}, {'end': 1060.183, 'text': "In Python, it's going to be that.", 'start': 1057.581, 'duration': 2.602}, {'end': 1063.365, 'text': "So we've gotten rid of the type still.", 'start': 1061.344, 'duration': 2.021}, {'end': 1066.788, 'text': "We've gotten rid of any mention of let or another keyword.", 'start': 1063.485, 'duration': 3.303}, {'end': 1072.283, 'text': "And we've gotten rid of, perhaps most gratifyingly, Semicolons are gone.", 'start': 1066.948, 'duration': 5.335}, {'end': 1076.505, 'text': "No more semicolons and no more curly braces in the way you've seen them thus far.", 'start': 1072.463, 'duration': 4.042}, {'end': 1079.407, 'text': 'So that was C, JavaScript, and now Python.', 'start': 1076.805, 'duration': 2.602}, {'end': 1084.45, 'text': 'So how about something like this? In Scratch, if you wanted to increment a counter by one, you would use a block like this.', 'start': 1079.467, 'duration': 4.983}], 'summary': 'Python eliminates type declarations, keywords, semicolons, and curly braces. scratch uses blocks to increment a counter.', 'duration': 29.41, 'max_score': 1055.04, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU1055040.jpg'}], 'start': 336.626, 'title': 'Web development and programming languages', 'summary': 'Explains website redirection, html, css, and javascript for web manipulation, and script tag placement in javascript for dom manipulation. it also discusses scratch, c, javascript, and python, emphasizing varied levels of abstraction and practical demonstrations, and compares python with other languages, highlighting its concise syntax, indentation importance, and various functionalities.', 'chapters': [{'end': 578.722, 'start': 336.626, 'title': 'Web development fundamentals', 'summary': 'Explains the process of website redirection, the use of html, css, and javascript to manipulate web pages, and the placement of script tags in javascript for manipulating the dom, highlighting the efficiency and structure in web development.', 'duration': 242.096, 'highlights': ['The process of website redirection is explained, where typing cs50.harvard.edu redirects the user to a more specific page depending on the time of year.', "HTML and its purpose of structuring and tagging web page content for the browser's convenience is discussed, emphasizing its role in providing HTTP headers and HTML content in web responses.", 'The significance of CSS in enhancing web page aesthetics and user experience is explained, highlighting its control over font size, positioning, and other visual aspects of the website.', 'The recommendation to factor out CSS from HTML pages for better maintenance and efficiency is provided, emphasizing the avoidance of repetitive copying and pasting of CSS styles across multiple files.', "JavaScript's role in manipulating the tree structure of web pages is detailed, highlighting its capability to make web content dynamic and constantly changing, as seen in platforms like Gmail and Facebook.", 'The importance of placing script tags in JavaScript at the bottom of the file for manipulating the DOM efficiently is explained, emphasizing the need for the tree structure to exist when the code is executed.']}, {'end': 1018.956, 'start': 579.448, 'title': 'Comparing programming languages', 'summary': 'Discusses the differences and applications of scratch, c, javascript, and python, emphasizing the varied levels of abstraction and the benefits of using the right language for the job, with a practical demonstration of resizing an image in python using library code.', 'duration': 439.508, 'highlights': ['The chapter discusses the differences and applications of Scratch, C, JavaScript, and Python. The chapter introduces the discussion by comparing different programming languages such as Scratch, C, JavaScript, and Python.', 'Emphasizing the varied levels of abstraction and the benefits of using the right language for the job. It highlights the importance of different levels of abstraction offered by languages like C, Python, and JavaScript, and the benefits of using the right tool for the job.', 'Practical demonstration of resizing an image in Python using library code. The instructor demonstrates the practicality of Python by resizing an image using library code, emphasizing the ease and efficiency of solving problems with the right language and tools.']}, {'end': 1357.242, 'start': 1019.276, 'title': 'Python language comparison', 'summary': "Discusses the similarities and differences between scratch, c, javascript, and python, emphasizing python's concise syntax, elimination of semicolons and curly braces, and the importance of indentation for logic, with examples of variable assignments, incrementing, if conditions, loops, and data types.", 'duration': 337.966, 'highlights': ['Python eliminates semicolons and curly braces, making its syntax more concise compared to C and JavaScript.', 'Python enforces proper indentation for logic, forcing the adoption of good stylistic habits.', "Python's for loop syntax is more succinct compared to C and JavaScript, using 'for i in range of 50' instead of explicit initialization, incrementation, and checking.", 'Python introduces a more limited set of data types, including bools, floats, ints, and strs, but also provides powerful additional data types like dictionaries, lists, and range.']}], 'duration': 1020.616, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU336626.jpg', 'highlights': ["JavaScript's role in manipulating the tree structure of web pages is detailed, highlighting its capability to make web content dynamic and constantly changing.", 'The recommendation to factor out CSS from HTML pages for better maintenance and efficiency is provided, emphasizing the avoidance of repetitive copying and pasting of CSS styles across multiple files.', 'The process of website redirection is explained, where typing cs50.harvard.edu redirects the user to a more specific page depending on the time of year.', 'The chapter discusses the differences and applications of Scratch, C, JavaScript, and Python, emphasizing varied levels of abstraction and practical demonstrations.', 'Python eliminates semicolons and curly braces, making its syntax more concise compared to C and JavaScript.', 'Practical demonstration of resizing an image in Python using library code, emphasizing the ease and efficiency of solving problems with the right language and tools.']}, {'end': 2681.586, 'segs': [{'end': 1382.754, 'src': 'embed', 'start': 1357.782, 'weight': 0, 'content': [{'end': 1363.505, 'text': 'And then tuple is a combination of things kind of like for math when you have x comma y or latitude comma longitude.', 'start': 1357.782, 'duration': 5.723}, {'end': 1367.767, 'text': 'Any time you have pairs or triples or more of things, those are called tuples.', 'start': 1363.725, 'duration': 4.042}, {'end': 1371.869, 'text': 'And those are common in math courses and higher level CS theory classes as well.', 'start': 1367.847, 'duration': 4.022}, {'end': 1380.113, 'text': 'But we do give you, at least in this first week of our look at Python, a few functions from CS50, among them get float, get int, and get string.', 'start': 1372.209, 'duration': 7.904}, {'end': 1382.754, 'text': 'which behave exactly like their C counterparts.', 'start': 1380.413, 'duration': 2.341}], 'summary': 'Tuples are common in math and cs, and we learn python functions like get float, get int, and get string from cs50.', 'duration': 24.972, 'max_score': 1357.782, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU1357782.jpg'}, {'end': 1740.784, 'src': 'embed', 'start': 1715.357, 'weight': 1, 'content': [{'end': 1722.539, 'text': "But my god, it's just so tedious to write even the simplest of programs, because I have to do hash includes, standard IO dot h, int main void.", 'start': 1715.357, 'duration': 7.182}, {'end': 1724.82, 'text': 'I mean all of this syntactic overhead.', 'start': 1722.679, 'duration': 2.141}, {'end': 1730.361, 'text': "that's getting in the way of you just doing the work you care about, which, in simplest form here is just printing hello world.", 'start': 1724.82, 'duration': 5.541}, {'end': 1736.083, 'text': 'So Python and a lot of more modern languages, among them Ruby and PHP and others,', 'start': 1730.661, 'duration': 5.422}, {'end': 1740.784, 'text': 'just get rid of a lot of that overhead so that you can just get down to work more quickly right away.', 'start': 1736.083, 'duration': 4.701}], 'summary': 'Tedious syntax in programming hinders productivity. python and modern languages reduce overhead for quicker work.', 'duration': 25.427, 'max_score': 1715.357, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU1715357.jpg'}, {'end': 2290.872, 'src': 'embed', 'start': 2261.825, 'weight': 2, 'content': [{'end': 2265.628, 'text': 'so to speak, or we should make it truly division, like we all grew up learning in school.', 'start': 2261.825, 'duration': 3.803}, {'end': 2272.334, 'text': 'Python took the latter approach and made division mean division, true division, where if you divide 2 ints, you get back a float.', 'start': 2265.929, 'duration': 6.405}, {'end': 2276.638, 'text': "Of course, this is a problem if people want to write code that assumes that it's going to be truncated.", 'start': 2272.674, 'duration': 3.964}, {'end': 2278.94, 'text': 'That can actually be a powerful feature.', 'start': 2276.658, 'duration': 2.282}, {'end': 2285.047, 'text': "So it turns out, and you won't have terribly many occasions to use this, but the compromise in the world was all right.", 'start': 2279.381, 'duration': 5.666}, {'end': 2290.872, 'text': 'if you really want the old behavior of division in Python, we will give it back to you.', 'start': 2285.047, 'duration': 5.825}], 'summary': "Python's true division returns float, can give back old behavior if desired.", 'duration': 29.047, 'max_score': 2261.825, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU2261825.jpg'}, {'end': 2431.887, 'src': 'heatmap', 'start': 2354.282, 'weight': 0.992, 'content': [{'end': 2356.643, 'text': "So let's rerun this, 1, 10.", 'start': 2354.282, 'duration': 2.361}, {'end': 2359.787, 'text': "OK, ooh, that's a new one.", 'start': 2356.644, 'duration': 3.143}, {'end': 2371.511, 'text': 'What is going on there? I did define z in the line above it.', 'start': 2361.168, 'duration': 10.343}, {'end': 2373.772, 'text': 'And what was your comment? x plus y.', 'start': 2371.531, 'duration': 2.241}, {'end': 2373.992, 'text': 'DAVID J.', 'start': 2373.772, 'duration': 0.22}, {'end': 2376.493, 'text': 'I did use x plus y, but I think I would.', 'start': 2373.992, 'duration': 2.501}, {'end': 2377.753, 'text': "Oh, OK, I'm sorry.", 'start': 2376.713, 'duration': 1.04}, {'end': 2381.494, 'text': 'OK, so we can fix that.', 'start': 2377.773, 'duration': 3.721}, {'end': 2384.834, 'text': 'Sorry There.', 'start': 2382.594, 'duration': 2.24}, {'end': 2387.435, 'text': 'OK, so 1, 10.', 'start': 2385.915, 'duration': 1.52}, {'end': 2389.676, 'text': 'Hmm, still wrong.', 'start': 2387.435, 'duration': 2.241}, {'end': 2392.316, 'text': 'Good catch.', 'start': 2391.876, 'duration': 0.44}, {'end': 2392.836, 'text': 'Thank you, though.', 'start': 2392.376, 'duration': 0.46}, {'end': 2401.452, 'text': 'Why is 1 plus 2, 11? Or 1 plus 10, 11? Yeah.', 'start': 2394.197, 'duration': 7.255}, {'end': 2404.894, 'text': 'Wait, wait, wait.', 'start': 2404.274, 'duration': 0.62}, {'end': 2412.98, 'text': 'Sorry This brings me back to my earlier point as to how tired I am.', 'start': 2404.955, 'duration': 8.025}, {'end': 2414.541, 'text': 'So this is correct.', 'start': 2413.7, 'duration': 0.841}, {'end': 2418.584, 'text': 'So Python does math correctly.', 'start': 2414.601, 'duration': 3.983}, {'end': 2421.618, 'text': 'But OK, horrifying.', 'start': 2419.676, 'duration': 1.942}, {'end': 2422.058, 'text': 'All right.', 'start': 2421.758, 'duration': 0.3}, {'end': 2431.887, 'text': "so now let's do division and try to make the point I think I meant to make late last night, where, if I do 1 divided by 10, OK, 1 divided by 10,,", 'start': 2422.058, 'duration': 9.829}], 'summary': 'Debugging code, discussing math errors, and tiredness late at night.', 'duration': 77.605, 'max_score': 2354.282, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU2354282.jpg'}], 'start': 1357.782, 'title': "Python's syntax, differences from c, and floating point math", 'summary': "Introduces python's syntax, differences from c, and floating point math, highlighting tuples, cs50 functions, and python interpreter's role, discussing syntactic and mechanical contrasts between python and c, and demonstrating python's handling of floating point math, including precision limitations and implications for data science.", 'chapters': [{'end': 1607.13, 'start': 1357.782, 'title': 'Python syntax and interpretation', 'summary': "Introduces the concept of tuples, the usage of cs50 functions in python, the syntax for importing functions, and the difference between compiling and interpreting code in python, highlighting the python interpreter's role and performance reasons behind its usage.", 'duration': 249.348, 'highlights': ['The chapter introduces the concept of tuples, commonly used in math courses and higher level CS theory classes, and their relevance to Python programming.', 'The usage of CS50 functions in Python, such as get float, get int, and get string, is explained for writing code reminiscent of previous weeks.', 'The syntax for importing functions in Python from the CS50 library is discussed, emphasizing the precision and difference from C syntax.', "The difference between compiling and interpreting code in Python is explained, highlighting the Python interpreter's role in translating source code to bytecode for execution."]}, {'end': 2297.754, 'start': 1607.53, 'title': 'Differences between python and c', 'summary': 'Discusses the differences between python and c, highlighting the syntactic and mechanical contrasts, the reduced overhead in python, and the practical examples of writing and running simple programs in python, showcasing features such as string formatting and arithmetic operations.', 'duration': 690.224, 'highlights': ["Python eliminates syntactic overhead, making it easier to write simple programs, like printing 'hello world', without the need for main function, header files, semicolons, or explicit type definitions. Python simplifies program writing by eliminating syntactic elements such as main function, header files, semicolons, and explicit type definitions, allowing for straightforward tasks like printing 'hello world'.", "Python's print function automatically adds a space between arguments, and formatting strings involves using the 'f' prefix and curly braces for variable substitution and arithmetic operations. Python's print function automatically adds a space between arguments, and formatting strings involves using the 'f' prefix and curly braces for variable substitution and arithmetic operations, simplifying the process of string formatting.", "Python performs true division, returning a float when dividing two integers, and provides floor division using '//' for the old behavior of truncating the decimal part. Python performs true division, returning a float when dividing two integers, and provides floor division using '//' for the old behavior of truncating the decimal part, presenting a notable contrast to the historical division behavior in C."]}, {'end': 2681.586, 'start': 2298.034, 'title': 'Python floating point math', 'summary': "Demonstrates python's handling of floating point math, including division and precision limitations, as well as similarities to c and the implications for data science, stating that python has limitations in terms of precision and handling of large numbers similar to other languages like c, but it is important in data science to have precise mathematics, and special libraries are required to address precision limitations.", 'duration': 383.552, 'highlights': ["Python's handling of floating point math, including division and precision limitations The chapter demonstrates Python's handling of floating point math, including division and precision limitations.", 'Implications for data science and analytics It is important in data science to have precise mathematics, and special libraries are required to address precision limitations.', 'Similarities to C in terms of precision limitations Python has limitations in terms of precision and handling of large numbers similar to other languages like C.']}], 'duration': 1323.804, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU1357782.jpg', 'highlights': ['The chapter introduces the concept of tuples, commonly used in math courses and higher level CS theory classes, and their relevance to Python programming.', "Python eliminates syntactic overhead, making it easier to write simple programs, like printing 'hello world', without the need for main function, header files, semicolons, or explicit type definitions.", "Python's handling of floating point math, including division and precision limitations The chapter demonstrates Python's handling of floating point math, including division and precision limitations."]}, {'end': 3684.612, 'segs': [{'end': 2786.491, 'src': 'embed', 'start': 2757.043, 'weight': 0, 'content': [{'end': 2758.023, 'text': "And indeed, that's the case.", 'start': 2757.043, 'duration': 0.98}, {'end': 2763.584, 'text': "The reason Python is not actually this slow, it's because we're running a web-based IDE, and the internet itself is a little slow.", 'start': 2758.263, 'duration': 5.321}, {'end': 2766.165, 'text': "And so what's happening here is just the internet is getting in the way.", 'start': 2763.864, 'duration': 2.301}, {'end': 2770.706, 'text': 'But suffice it to say that Python is counting up way, way higher than C was.', 'start': 2766.425, 'duration': 4.281}, {'end': 2773.106, 'text': "And that's the power you get by just using larger data types.", 'start': 2770.806, 'duration': 2.3}, {'end': 2774.527, 'text': 'We could have done this in C.', 'start': 2773.146, 'duration': 1.381}, {'end': 2776.247, 'text': 'We could have used longs, for instance.', 'start': 2774.527, 'duration': 1.72}, {'end': 2780.188, 'text': 'But notice that with Python, you just get more, by default, out of the box.', 'start': 2776.467, 'duration': 3.721}, {'end': 2782.149, 'text': "Let's go ahead and take a five minute break here.", 'start': 2780.508, 'duration': 1.641}, {'end': 2785.33, 'text': "And when we resume, we'll introduce some more syntax and solve some more problems.", 'start': 2782.169, 'duration': 3.161}, {'end': 2786.491, 'text': 'All right.', 'start': 2786.051, 'duration': 0.44}], 'summary': 'Python outperforms c with larger data types, despite web-based ide slowdowns.', 'duration': 29.448, 'max_score': 2757.043, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU2757043.jpg'}, {'end': 3165.252, 'src': 'embed', 'start': 3136.223, 'weight': 1, 'content': [{'end': 3139.206, 'text': 'A coughing, at least in our textual form, is just the act of printing something.', 'start': 3136.223, 'duration': 2.983}, {'end': 3145.367, 'text': 'So we introduced in version 2 some time ago the following approach in cough 2.', 'start': 3139.486, 'duration': 5.881}, {'end': 3149.068, 'text': 'I instead defined a function called cough that did the coughing for me.', 'start': 3145.367, 'duration': 3.701}, {'end': 3150.389, 'text': "And we've not seen this yet in Python.", 'start': 3149.088, 'duration': 1.301}, {'end': 3153.209, 'text': 'So how do you define a function in Python called cough??', 'start': 3150.409, 'duration': 2.8}, {'end': 3157.91, 'text': 'Put another way, how do you make your own custom puzzle piece, just as we did in Scratch?', 'start': 3153.349, 'duration': 4.561}, {'end': 3161.011, 'text': 'Well, you define it with def and then you have it.', 'start': 3158.29, 'duration': 2.721}, {'end': 3165.252, 'text': 'do exactly what you want it to do, by just indenting the lines of code that belong to that function.', 'start': 3161.011, 'duration': 4.241}], 'summary': "In python, a function called cough is introduced in version 2, allowing users to define custom puzzle pieces using the 'def' keyword and indenting the lines of code that belong to that function.", 'duration': 29.029, 'max_score': 3136.223, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU3136223.jpg'}, {'end': 3625.676, 'src': 'embed', 'start': 3599.976, 'weight': 2, 'content': [{'end': 3610.173, 'text': "Yes? Ah, how did I define n as an integer? This is what's nice about Python.", 'start': 3599.976, 'duration': 10.197}, {'end': 3614.774, 'text': 'If you want a variable or a parameter, just start using it without mentioning its data type.', 'start': 3610.193, 'duration': 4.581}, {'end': 3621.935, 'text': 'So the fact that I put n in parentheses in this function means, hey, Python, let this function take an input called n.', 'start': 3614.854, 'duration': 7.081}, {'end': 3625.676, 'text': 'And it can actually be any data type, int, float, string, or even something else.', 'start': 3621.935, 'duration': 3.741}], 'summary': "In python, defining a variable or parameter doesn't require specifying its data type, allowing flexibility in accepting various data types.", 'duration': 25.7, 'max_score': 3599.976, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU3599976.jpg'}], 'start': 2681.646, 'title': 'Python programming features', 'summary': "Covers python overflow issue, syntax and features, functions and program structure, and function parameterization. it highlights the use of new libraries, python's handling of large data types, function definition, and runtime behavior with examples.", 'chapters': [{'end': 2724.22, 'start': 2681.646, 'title': 'Python overflow issue', 'summary': "Discusses the issue of overflow in the context of integers, and introduces a python program that demonstrates the use of a new library 'time' for introducing delays.", 'duration': 42.574, 'highlights': ['The chapter discusses the issue of overflow in the context of integers.', "Introduces a Python program that demonstrates the use of a new library 'time' for introducing delays."]}, {'end': 3058.697, 'start': 2724.68, 'title': 'Python syntax and features', 'summary': "Discusses python's ability to handle large data types, the importance of consistent indentation, the trim syntax of python, and the use of equal equals for string comparison, showing python's suitability for logical expression and control flow.", 'duration': 334.017, 'highlights': ["Python's ability to handle large data types allows it to count higher than C, showcasing the power of using larger data types. Python's ability to count up way higher than C was shown, demonstrating the power of using larger data types.", 'The importance of consistent indentation in Python is emphasized, with the requirement of consistent indentation and consistent use of colons, along with the minimalistic and pythonic approach to syntax. The importance of consistent indentation and colons in Python, along with its minimalistic and pythonic approach to syntax, was emphasized.', "Python's use of equal equals for string comparison simplifies the code and makes it more readable, eliminating the need for pointer comparison and making it easier to write and understand. Python's use of equal equals for string comparison simplifies the code, eliminates the need for pointer comparison, and makes it easier to write and understand."]}, {'end': 3421.76, 'start': 3058.697, 'title': 'Python functions and program structure', 'summary': 'Explains the concept of defining and using functions in python, highlighting the importance of main function and program structure, and it also addresses common errors when calling functions.', 'duration': 363.063, 'highlights': ["The chapter explains the concept of defining and using functions in Python. It introduces the concept of defining a function in Python using 'def' and demonstrates the use of a function called 'cough' to simulate coughing.", 'The importance of main function and program structure is highlighted. It emphasizes the significance of defining a main function in Python to avoid errors when calling functions and demonstrates the need to call the main function explicitly.', 'Common errors when calling functions are addressed. The chapter explains the error of calling a function before it is defined in Python and presents the solution of defining a main function to address this issue.']}, {'end': 3684.612, 'start': 3422.08, 'title': 'Python function parameterization', 'summary': "Discusses parameterizing a cough function in python, utilizing a custom puzzle piece abstraction, and the runtime behavior of python functions with examples and explanations of python's loosely typed nature and convention.", 'duration': 262.532, 'highlights': ['Python functions can be parameterized without specifying data types, allowing for flexibility in the type of input, such as int, float, or string. The Python function parameterization allows for the flexibility of the input data type, such as int, float, string, or others, providing a more dynamic approach to coding.', 'Python is loosely typed, allowing variables to change type during program execution, which requires responsible usage and adherence to conventions. Python is loosely typed, enabling variables to change type during program execution, though responsible usage and adherence to conventions are emphasized to avoid potential bugs.', 'The chapter demonstrates the process of parameterizing a cough function in Python, solidifying the concept of abstraction and the use of a main function to execute programs. The chapter illustrates the parameterization of a cough function in Python, emphasizing the concept of abstraction and the utilization of a main function to execute programs.']}], 'duration': 1002.966, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU2681646.jpg', 'highlights': ["Python's ability to handle large data types allows it to count higher than C, showcasing the power of using larger data types.", "The chapter explains the concept of defining and using functions in Python. It introduces the concept of defining a function in Python using 'def' and demonstrates the use of a function called 'cough' to simulate coughing.", 'Python functions can be parameterized without specifying data types, allowing for flexibility in the type of input, such as int, float, or string.']}, {'end': 4431.693, 'segs': [{'end': 3832.276, 'src': 'embed', 'start': 3803.966, 'weight': 4, 'content': [{'end': 3805.887, 'text': 'Do while just is a nice handy feature.', 'start': 3803.966, 'duration': 1.921}, {'end': 3807.248, 'text': 'But we can simulate it.', 'start': 3806.127, 'duration': 1.121}, {'end': 3809.689, 'text': 'And the Pythonic way of doing this is as follows.', 'start': 3807.508, 'duration': 2.181}, {'end': 3812.091, 'text': 'Deliberately induce an infinite loop.', 'start': 3810.049, 'duration': 2.042}, {'end': 3814.371, 'text': 'because you do want to loop potentially.', 'start': 3812.551, 'duration': 1.82}, {'end': 3820.213, 'text': "But the logic is going to be, give me an infinite loop, and I will break out of it when I'm ready to break out of it.", 'start': 3814.692, 'duration': 5.521}, {'end': 3821.393, 'text': 'This would be the convention.', 'start': 3820.393, 'duration': 1}, {'end': 3823.614, 'text': 'So while the following is true, do this.', 'start': 3821.753, 'duration': 1.861}, {'end': 3828.395, 'text': 'Go ahead and declare a variable called n, get an int from the user, and pass in that same prompt.', 'start': 3823.714, 'duration': 4.681}, {'end': 3829.895, 'text': 'So get int, we wrote, the staff.', 'start': 3828.415, 'duration': 1.48}, {'end': 3832.276, 'text': 'Prompt is whatever I typed in up here.', 'start': 3830.455, 'duration': 1.821}], 'summary': "In python, simulating a 'do while' loop involves deliberately inducing an infinite loop and breaking out of it when ready.", 'duration': 28.31, 'max_score': 3803.966, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU3803966.jpg'}, {'end': 3990.732, 'src': 'embed', 'start': 3962.516, 'weight': 0, 'content': [{'end': 3967.079, 'text': 'And we defined it essentially casually between two curly braces, the most recently opened curly braces.', 'start': 3962.516, 'duration': 4.563}, {'end': 3968.339, 'text': 'Well, no curly braces anymore.', 'start': 3967.099, 'duration': 1.24}, {'end': 3972.161, 'text': 'So it turns out that variables by default have function scope here.', 'start': 3968.639, 'duration': 3.522}, {'end': 3977.804, 'text': 'So when you declare n on line 9, you can use it in Python on line 10.', 'start': 3972.562, 'duration': 5.242}, {'end': 3980.806, 'text': 'And you know what? You can even use it on line 12.', 'start': 3977.804, 'duration': 3.002}, {'end': 3984.348, 'text': 'even though it was declared inside of this loop higher up.', 'start': 3980.806, 'duration': 3.542}, {'end': 3990.732, 'text': 'So once you declare a variable on this line, you can use it anywhere on a subsequent line within that same function.', 'start': 3984.789, 'duration': 5.943}], 'summary': 'Python variables have function scope, allowing use within the same function.', 'duration': 28.216, 'max_score': 3962.516, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU3962516.jpg'}, {'end': 4126.292, 'src': 'embed', 'start': 4101.805, 'weight': 2, 'content': [{'end': 4108.452, 'text': "It turns out that Python has not only positional arguments, as it's called, whereby you just pass in arguments between commas.", 'start': 4101.805, 'duration': 6.647}, {'end': 4109.473, 'text': "That's what we've been doing in C.", 'start': 4108.511, 'duration': 0.962}, {'end': 4117.964, 'text': 'But Python also has named arguments, whereby you can specify the name of the argument, then an equal sign, then the value.', 'start': 4110.113, 'duration': 7.851}, {'end': 4126.292, 'text': 'And the power of named arguments, even though this is a tiny example, means that you can sometimes pass in your arguments in any order.', 'start': 4118.243, 'duration': 8.049}], 'summary': 'Python has both positional and named arguments, allowing non-sequential parameter passing.', 'duration': 24.487, 'max_score': 4101.805, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU4101805.jpg'}, {'end': 4252.135, 'src': 'embed', 'start': 4223.603, 'weight': 1, 'content': [{'end': 4227.145, 'text': 'But in that container or structure is also built-in functions.', 'start': 4223.603, 'duration': 3.542}, {'end': 4229.507, 'text': 'features of a string that you can just call.', 'start': 4227.625, 'duration': 1.882}, {'end': 4237.438, 'text': 'So in C, we would have said something like toUpper and then passed as input to a function called toUpper, the character that we care about.', 'start': 4229.868, 'duration': 7.57}, {'end': 4239.701, 'text': 'Python kind of flips the logic around.', 'start': 4237.778, 'duration': 1.923}, {'end': 4246.85, 'text': 'Strings come with built-in functionality that allow you to operate on the given character automatically.', 'start': 4240.221, 'duration': 6.629}, {'end': 4249.713, 'text': 'So in Python, the syntax is actually the character itself.', 'start': 4247.15, 'duration': 2.563}, {'end': 4252.135, 'text': "Use the dot notation, because it's a structure.", 'start': 4250.193, 'duration': 1.942}], 'summary': 'Python strings have built-in functions for character operations.', 'duration': 28.532, 'max_score': 4223.603, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU4223603.jpg'}, {'end': 4362.222, 'src': 'embed', 'start': 4326.764, 'weight': 3, 'content': [{'end': 4328.125, 'text': "In Python, it's a little different.", 'start': 4326.764, 'duration': 1.361}, {'end': 4330.206, 'text': 'You actually just say len for length.', 'start': 4328.165, 'duration': 2.041}, {'end': 4337.318, 'text': 'So if I go ahead and run this through strlen, strlen, type in my name, hopefully I indeed see 5.', 'start': 4330.666, 'duration': 6.652}, {'end': 4343.308, 'text': "And there's no notion that you need to care about the backslash 0 in order to terminate the string.", 'start': 4337.318, 'duration': 5.99}, {'end': 4351.935, 'text': 'Yeah? DAVID J.', 'start': 4343.408, 'duration': 8.527}, {'end': 4352.695, 'text': 'No, in fact.', 'start': 4351.935, 'duration': 0.76}, {'end': 4354.717, 'text': "So that's a really good observation.", 'start': 4352.936, 'duration': 1.781}, {'end': 4362.222, 'text': "Let's rewind and actually improve upon this, rather than just translate it from what was our comparable example in C.", 'start': 4354.757, 'duration': 7.465}], 'summary': 'In python, use len for length, no need to care about string termination.', 'duration': 35.458, 'max_score': 4326.764, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU4326764.jpg'}], 'start': 3685.172, 'title': 'Pythonic approach to user input and python strings and arrays', 'summary': "Covers the pythonic approach to user input, including an infinite loop for do-while simulation and function scope comparison to c. it also introduces python strings and arrays, showcasing built-in functions for string manipulation, emphasizing python's advantages over c.", 'chapters': [{'end': 4003.207, 'start': 3685.172, 'title': 'Pythonic approach to user input in python', 'summary': 'Explains the pythonic approach to handling user input, including the use of an infinite loop to simulate a do-while loop in c and the concept of function scope in python, while comparing it to the c programming paradigm.', 'duration': 318.035, 'highlights': ['The Pythonic way of handling user input involves deliberately inducing an infinite loop and breaking out of it when ready, instead of using the do-while loop from C, demonstrating the difference in handling user input between Python and C.', "Variables in Python have function scope by default, allowing them to be used anywhere within the same function after declaration, simplifying the process of variable usage compared to C's scope handling."]}, {'end': 4431.693, 'start': 4003.207, 'title': 'Python strings and arrays', 'summary': "Introduces python strings and arrays, demonstrating the use of built-in functions to capitalize and determine the length of strings, highlighting the differences between python and c and emphasizing the advantages of python's expressiveness and object-oriented programming.", 'duration': 428.486, 'highlights': ['Python strings have built-in functionality like the upper function, allowing for automatic operation on characters, in contrast to C where such features are not built into strings. Python strings come with built-in functionality that allow you to operate on the given character automatically, such as using the dot notation to call built-in functions like upper.', 'Python 3 supports named arguments and optional arguments, providing flexibility in passing arguments and allowing for default values, unlike C. Python supports named arguments, allowing for flexibility in passing arguments in any order and optional arguments with default values, providing more flexibility compared to C.', "Python's len function is used to determine the length of a string, in contrast to the strlen function in C, demonstrating a simpler approach in Python. In Python, the len function is used to determine the length of a string, providing a simpler approach compared to the strlen function in C."]}], 'duration': 746.521, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU3685172.jpg', 'highlights': ['Variables in Python have function scope by default, simplifying variable usage compared to C.', 'Python strings have built-in functionality like the upper function, allowing for automatic operation on characters, in contrast to C.', 'Python 3 supports named arguments and optional arguments, providing flexibility in passing arguments and allowing for default values, unlike C.', "Python's len function is used to determine the length of a string, demonstrating a simpler approach in Python.", 'The Pythonic way of handling user input involves deliberately inducing an infinite loop and breaking out of it when ready, instead of using the do-while loop from C.']}, {'end': 5228.627, 'segs': [{'end': 4504.742, 'src': 'embed', 'start': 4447.783, 'weight': 0, 'content': [{'end': 4454.846, 'text': "But if we focus down here, what you're generally going to want to look for, at least for the official documentation, is docs.python.org.", 'start': 4447.783, 'duration': 7.063}, {'end': 4457.227, 'text': "You see in the URL, it's version 3.", 'start': 4455.086, 'duration': 2.141}, {'end': 4458.247, 'text': "And that's where we want to go.", 'start': 4457.227, 'duration': 1.02}, {'end': 4460.688, 'text': 'So let me go ahead and click on this, common string operators.', 'start': 4458.347, 'duration': 2.341}, {'end': 4462.249, 'text': 'And I will disclaim this.', 'start': 4461.028, 'duration': 1.221}, {'end': 4466.732, 'text': "I think, personally, Python's documentation is not terribly newbie friendly.", 'start': 4462.609, 'duration': 4.123}, {'end': 4470.294, 'text': "It's written fairly arcanely, and you kind of have to really dig to understand certain things.", 'start': 4466.772, 'duration': 3.522}, {'end': 4471.435, 'text': "That's fine.", 'start': 4470.775, 'duration': 0.66}, {'end': 4473.016, 'text': "You'll get comfortable with it over time.", 'start': 4471.455, 'duration': 1.561}, {'end': 4478.46, 'text': "But if you're feeling a little overwhelmed by, oh my god, I just want to know about upper, everyone feels this way too.", 'start': 4473.056, 'duration': 5.404}, {'end': 4481.922, 'text': 'So Control-F or Command-F is your friend, upper.', 'start': 4479.08, 'duration': 2.842}, {'end': 4483.663, 'text': 'Let me go ahead and search for this.', 'start': 4482.302, 'duration': 1.361}, {'end': 4487.806, 'text': "And it's not actually on this page, is it? String.", 'start': 4484.724, 'duration': 3.082}, {'end': 4490.513, 'text': 'Ah, string methods.', 'start': 4489.312, 'duration': 1.201}, {'end': 4491.554, 'text': 'Here we go, string methods.', 'start': 4490.553, 'duration': 1.001}, {'end': 4495.456, 'text': 'OK, so under string methods, let me go ahead and search for upper.', 'start': 4492.174, 'duration': 3.282}, {'end': 4498.959, 'text': 'And down here, indeed, is the documentation.', 'start': 4496.817, 'duration': 2.142}, {'end': 4504.742, 'text': 'So the convention will be the name of the data type in question, str for string, the name of the function here.', 'start': 4499.039, 'duration': 5.703}], 'summary': 'Python documentation can be challenging, but using control-f or command-f can help navigate it effectively.', 'duration': 56.959, 'max_score': 4447.783, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU4447783.jpg'}, {'end': 4568.32, 'src': 'embed', 'start': 4539.143, 'weight': 3, 'content': [{'end': 4543.386, 'text': 'you can call strip on a string and get rid of whitespace to the left and right to kind of clean it up.', 'start': 4539.143, 'duration': 4.243}, {'end': 4548.369, 'text': 'Terribly useful for things like data science applications and analysis of data, where you just kind of clean up messy data.', 'start': 4543.746, 'duration': 4.623}, {'end': 4551.13, 'text': 'So many functions like that are built in for you.', 'start': 4548.769, 'duration': 2.361}, {'end': 4557.894, 'text': "All right, so let's take a look at a few other examples reminiscent of features we did have in C, such as this one here.", 'start': 4551.691, 'duration': 6.203}, {'end': 4564.218, 'text': "Suppose I want to write a program that takes command line arguments, much like resize, with which we started today's story.", 'start': 4557.994, 'duration': 6.224}, {'end': 4568.32, 'text': "Rather, let's not even use the CS50 library.", 'start': 4566.179, 'duration': 2.141}], 'summary': 'Using the strip function to remove whitespace from strings is useful in data science, and there are many built-in functions for such purposes.', 'duration': 29.177, 'max_score': 4539.143, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU4539143.jpg'}, {'end': 4606.704, 'src': 'embed', 'start': 4580.835, 'weight': 5, 'content': [{'end': 4585.301, 'text': "Well, unfortunately, if you're not using main, it would be nice if you can still use command line arguments.", 'start': 4580.835, 'duration': 4.466}, {'end': 4586.943, 'text': 'And you can, but you have to import them.', 'start': 4585.341, 'duration': 1.602}, {'end': 4588.805, 'text': "It's a library that provides you with access.", 'start': 4587.063, 'duration': 1.742}, {'end': 4593.63, 'text': 'from the sys or system library, you can import argv in Python.', 'start': 4589.305, 'duration': 4.325}, {'end': 4596.413, 'text': 'And that gives you access to command line arguments as a feature.', 'start': 4593.71, 'duration': 2.703}, {'end': 4598.075, 'text': 'Then you can say something like this.', 'start': 4596.833, 'duration': 1.242}, {'end': 4606.704, 'text': 'If the length of argv, which is just an array, recall, in C, equals equals 2, then go ahead and say, hello.', 'start': 4598.475, 'duration': 8.229}], 'summary': 'Using argv in python provides access to command line arguments, allowing for conditional actions.', 'duration': 25.869, 'max_score': 4580.835, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU4580835.jpg'}, {'end': 4917.123, 'src': 'embed', 'start': 4876.295, 'weight': 2, 'content': [{'end': 4880.377, 'text': "So there's an actual underlying mental model for what's going on here.", 'start': 4876.295, 'duration': 4.082}, {'end': 4884.038, 'text': "But in effect, you're literally switching them, and you don't need the temporary variable.", 'start': 4880.637, 'duration': 3.401}, {'end': 4887.66, 'text': 'Python, the language, takes care of that for you.', 'start': 4884.318, 'duration': 3.342}, {'end': 4893.847, 'text': "All right, let's look at a more powerful feature still, this time using what's actually called a list.", 'start': 4888.624, 'duration': 5.223}, {'end': 4897.95, 'text': 'So a moment ago, I was using argv as our examples.', 'start': 4893.967, 'duration': 3.983}, {'end': 4899.691, 'text': 'And I was calling them arrays.', 'start': 4897.97, 'duration': 1.721}, {'end': 4901.172, 'text': "They're not arrays anymore.", 'start': 4900.091, 'duration': 1.081}, {'end': 4902.813, 'text': 'Python does not have arrays.', 'start': 4901.252, 'duration': 1.561}, {'end': 4904.174, 'text': 'Python has lists.', 'start': 4903.073, 'duration': 1.101}, {'end': 4907.536, 'text': 'And lists sounds reminiscent of linked lists, and indeed they are.', 'start': 4904.694, 'duration': 2.842}, {'end': 4910.738, 'text': 'In Python, you have lists that are resizable.', 'start': 4907.836, 'duration': 2.902}, {'end': 4913.701, 'text': "You don't have to decide in advance how big they are or how small they are.", 'start': 4910.839, 'duration': 2.862}, {'end': 4917.123, 'text': 'They will just grow and shrink for you, just like a linked list will.', 'start': 4913.861, 'duration': 3.262}], 'summary': 'Python uses lists, which are resizable and function like linked lists, eliminating the need for temporary variables.', 'duration': 40.828, 'max_score': 4876.295, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU4876295.jpg'}, {'end': 4987.74, 'src': 'embed', 'start': 4953.002, 'weight': 1, 'content': [{'end': 4956.985, 'text': "You have to use a for loop or a while loop to iterate over the whole thing to find what you're looking for.", 'start': 4953.002, 'duration': 3.983}, {'end': 4962.51, 'text': 'In Python, if something is in a list, you can just use, yes, the square brackets to get at that specific element.', 'start': 4957.366, 'duration': 5.144}, {'end': 4966.906, 'text': 'Oh, I could have.', 'start': 4965.965, 'duration': 0.941}, {'end': 4971.951, 'text': "Yes, I didn't use the F just because, frankly, it just gets ugly eventually.", 'start': 4967.266, 'duration': 4.685}, {'end': 4975.875, 'text': 'But yes, I could have also done this to achieve the exact same effect.', 'start': 4972.292, 'duration': 3.583}, {'end': 4977.257, 'text': 'It just starts to look cryptic.', 'start': 4976.216, 'duration': 1.041}, {'end': 4987.74, 'text': "OK, so let's actually introduce a list, which itself is a data type in Python as well as in languages like C++ and Java,", 'start': 4978.717, 'duration': 9.023}], 'summary': 'Using loops to iterate over lists in python and avoiding cryptic code.', 'duration': 34.738, 'max_score': 4953.002, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU4953002.jpg'}], 'start': 4432.053, 'title': 'Python 3 documentation and functions', 'summary': 'Covers the process of finding official python 3 string documentation, emphasizing the importance of avoiding outdated tutorials and directing users to the official documentation at docs.python.org. it also highlights built-in functions in python, usage of command line arguments, for loops, swapping variables, and the use of python lists.', 'chapters': [{'end': 4521.033, 'start': 4432.053, 'title': 'Finding official python 3 string documentation', 'summary': 'Highlights the process of finding the official python 3 string documentation, emphasizing the importance of avoiding outdated tutorials and directing users to the official documentation at docs.python.org, although acknowledging its complexity, and provides tips for efficient navigation and understanding, such as using control-f or command-f for quick searching.', 'duration': 88.98, 'highlights': ['The chapter emphasizes the importance of navigating to the official Python 3 documentation at docs.python.org to avoid outdated tutorials and documentation.', "It acknowledges the complexity of Python's documentation, suggesting that users will become comfortable with it over time, but provides a tip for quick navigation and understanding by using Control-F or Command-F for searching.", "The chapter explores the process of searching for the 'upper' string method in the official Python 3 documentation, highlighting the convention of the function's name and its behavior, which returns a copy of the string with all cased characters converted to uppercase."]}, {'end': 5228.627, 'start': 4521.133, 'title': 'Python functions and features', 'summary': 'Highlights the built-in functions in python such as strip, the usage of command line arguments, for loops with strings and lists, swapping variables, and the use of python lists with features like append and conditional list operations.', 'duration': 707.494, 'highlights': ['Python provides built-in functions like strip for cleaning up data, which is useful for data science applications and analysis of data. The strip function in Python is useful for cleaning up messy data and is particularly helpful for data science applications and data analysis.', 'The usage of command line arguments in Python using the sys library allows for similar functionality as in C, with the ability to access and manipulate command line arguments. Python allows access to command line arguments using the sys library, providing similar functionality as in C for accessing and manipulating command line arguments.', "Python's for loop provides an easy way to iterate over arrays and strings without the need for explicit index manipulation. Python's for loop simplifies the iteration process over arrays and strings by eliminating the need for explicit index manipulation, providing a more concise and readable code.", 'Python allows for the swapping of variables without the need for a temporary variable, simplifying the process of variable swapping. Python provides a simple and direct method for swapping variables without requiring a temporary variable, streamlining the process of variable swapping.', "Python's lists, which are resizable, provide the ability to perform operations like appending elements and conditional list operations in a more English-like syntax. Python's lists, being resizable, allow for operations such as appending elements and conditional list operations with a syntax that reads more like English, simplifying the process of working with lists."]}], 'duration': 796.574, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU4432053.jpg', 'highlights': ['The chapter emphasizes the importance of navigating to the official Python 3 documentation at docs.python.org to avoid outdated tutorials and documentation.', "Python's for loop simplifies the iteration process over arrays and strings by eliminating the need for explicit index manipulation, providing a more concise and readable code.", "Python's lists, being resizable, allow for operations such as appending elements and conditional list operations with a syntax that reads more like English, simplifying the process of working with lists.", 'Python provides built-in functions like strip for cleaning up data, which is useful for data science applications and analysis of data.', 'Python allows for the swapping of variables without the need for a temporary variable, streamlining the process of variable swapping.', 'The usage of command line arguments in Python using the sys library allows for similar functionality as in C, with the ability to access and manipulate command line arguments.', "The chapter explores the process of searching for the 'upper' string method in the official Python 3 documentation, highlighting the convention of the function's name and its behavior, which returns a copy of the string with all cased characters converted to uppercase.", "It acknowledges the complexity of Python's documentation, suggesting that users will become comfortable with it over time, but provides a tip for quick navigation and understanding by using Control-F or Command-F for searching."]}, {'end': 6140.561, 'segs': [{'end': 5321.23, 'src': 'embed', 'start': 5289.808, 'weight': 0, 'content': [{'end': 5293.03, 'text': "Now, there's many ways we can solve this, but let me propose the simplest one.", 'start': 5289.808, 'duration': 3.222}, {'end': 5298.814, 'text': 'It turns out in Python, you can declare hash tables so wonderfully simply.', 'start': 5293.35, 'duration': 5.464}, {'end': 5301.476, 'text': 'A hash table is just a collection of key value pairs.', 'start': 5299.134, 'duration': 2.342}, {'end': 5305.298, 'text': 'And I would argue, at this point in my example, I have keys and values.', 'start': 5301.556, 'duration': 3.742}, {'end': 5313.824, 'text': 'I have a name, which is a key, and the value, like David or whatever, another key called dorm, and then a value, which is like Matthews or wherever.', 'start': 5305.638, 'duration': 8.186}, {'end': 5315.345, 'text': 'and so keys and values.', 'start': 5314.184, 'duration': 1.161}, {'end': 5321.23, 'text': 'So it would be kind of nice if I could create for myself like a hash table, or even a try for that matter, that allows me to store this data.', 'start': 5315.505, 'duration': 5.725}], 'summary': 'Python allows for simple declaration of hash tables for storing key-value pairs.', 'duration': 31.422, 'max_score': 5289.808, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU5289808.jpg'}, {'end': 5516.773, 'src': 'embed', 'start': 5491.08, 'weight': 2, 'content': [{'end': 5498.085, 'text': "But it's nice to be able to refer to those not as 0 and 1 or some stupid arbitrary number, but rather by keys, name and dorm.", 'start': 5491.08, 'duration': 7.005}, {'end': 5504.629, 'text': 'So this syntax here, though cryptic, says go inside the student object and get me the value of the key called name.', 'start': 5498.385, 'duration': 6.244}, {'end': 5506.03, 'text': 'And this is the same thing.', 'start': 5504.989, 'duration': 1.041}, {'end': 5507.47, 'text': 'about dorm.', 'start': 5506.77, 'duration': 0.7}, {'end': 5514.012, 'text': 'So an object in Python, or more generally a hash table, allows you to associate keys with values.', 'start': 5507.83, 'duration': 6.182}, {'end': 5516.773, 'text': 'And this is quite simply the syntax you use for that.', 'start': 5514.072, 'duration': 2.701}], 'summary': 'Python objects associate keys with values for easy reference.', 'duration': 25.693, 'max_score': 5491.08, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU5491080.jpg'}, {'end': 5651.102, 'src': 'embed', 'start': 5619.46, 'weight': 3, 'content': [{'end': 5620.68, 'text': 'So mario 1.py.', 'start': 5619.46, 'duration': 1.22}, {'end': 5623.661, 'text': "Let's go ahead and print this out with a loop, for instance.", 'start': 5621.06, 'duration': 2.601}, {'end': 5631.564, 'text': 'So how do I do this? How do I print four question marks, but one at a time? Four i and, yep, range four.', 'start': 5624.421, 'duration': 7.143}, {'end': 5635.992, 'text': 'Print Question mark.', 'start': 5633.185, 'duration': 2.807}, {'end': 5642.317, 'text': "Save All right, so Python, Marios, anyone want to yell at? No, don't do that? OK, thanks.", 'start': 5636.593, 'duration': 5.724}, {'end': 5642.677, 'text': "That's great.", 'start': 5642.357, 'duration': 0.32}, {'end': 5646.159, 'text': "All right, so why did you not want me to do that? Because they're all vertical.", 'start': 5642.937, 'duration': 3.222}, {'end': 5648.04, 'text': 'So we did have a fix for this.', 'start': 5646.679, 'duration': 1.361}, {'end': 5651.102, 'text': "How do I tell print mm-mm don't end your lines with the default new line?", 'start': 5648.08, 'duration': 3.022}], 'summary': 'Using python, mario prints four question marks one at a time using a loop and learns to avoid ending lines with default new line.', 'duration': 31.642, 'max_score': 5619.46, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU5619460.jpg'}, {'end': 5712.359, 'src': 'embed', 'start': 5685.964, 'weight': 4, 'content': [{'end': 5689.706, 'text': 'So if we want to print out those three hashes, allow me to draw some inspiration from this.', 'start': 5685.964, 'duration': 3.742}, {'end': 5691.608, 'text': "And let's say in mario2.py.", 'start': 5689.766, 'duration': 1.842}, {'end': 5700.713, 'text': 'Let me go ahead and just say for i in range of 3, go ahead and print out just one block.', 'start': 5693.169, 'duration': 7.544}, {'end': 5702.934, 'text': "And as you've been advising, just do this.", 'start': 5701.013, 'duration': 1.921}, {'end': 5708.317, 'text': "Or rather, no, let's use the default to print out a vertical bar of three blocks.", 'start': 5703.595, 'duration': 4.722}, {'end': 5709.878, 'text': 'So this is mario2.py.', 'start': 5708.377, 'duration': 1.501}, {'end': 5712.359, 'text': "And now we've done something reminiscent of that.", 'start': 5710.258, 'duration': 2.101}], 'summary': 'In mario2.py, a vertical bar of three blocks is printed using a for loop.', 'duration': 26.395, 'max_score': 5685.964, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU5685964.jpg'}, {'end': 5930.114, 'src': 'heatmap', 'start': 5849.848, 'weight': 5, 'content': [{'end': 5853.611, 'text': 'And then that happens.', 'start': 5849.848, 'duration': 3.763}, {'end': 5854.992, 'text': 'And then we print a new line.', 'start': 5853.631, 'duration': 1.361}, {'end': 5857.414, 'text': 'And then it should execute that three times.', 'start': 5855.472, 'duration': 1.942}, {'end': 5859.275, 'text': 'All right.', 'start': 5858.495, 'duration': 0.78}, {'end': 5861.231, 'text': 'What do you think? The duck is convinced.', 'start': 5859.315, 'duration': 1.916}, {'end': 5864.754, 'text': "All right, why don't you guys save the file? Let's try.", 'start': 5863.132, 'duration': 1.622}, {'end': 5865.855, 'text': 'No harm in trying.', 'start': 5865.174, 'duration': 0.681}, {'end': 5867.777, 'text': "So right or wrong, let's see.", 'start': 5865.915, 'duration': 1.862}, {'end': 5869.999, 'text': 'This is called mario3.py.', 'start': 5868.097, 'duration': 1.902}, {'end': 5873.582, 'text': 'And I think we have a round of applause, if we could.', 'start': 5870.839, 'duration': 2.743}, {'end': 5874.483, 'text': 'Very nicely done.', 'start': 5873.742, 'duration': 0.741}, {'end': 5876.182, 'text': 'All right.', 'start': 5875.962, 'duration': 0.22}, {'end': 5877.723, 'text': "So let's end if you'd like one more.", 'start': 5876.562, 'duration': 1.161}, {'end': 5882.805, 'text': "So let's take a look at one final example coming full circle from where we began.", 'start': 5878.383, 'duration': 4.422}, {'end': 5884.225, 'text': 'We, of course, looked at resize.', 'start': 5882.845, 'duration': 1.38}, {'end': 5891.187, 'text': "And let's open that up just to see how I got away with writing so little code and actually getting that job done.", 'start': 5884.325, 'duration': 6.862}, {'end': 5897.37, 'text': 'So in resize.py, which is where we began, notice that I had a few lines that hopefully look a little more familiar now.', 'start': 5891.388, 'duration': 5.982}, {'end': 5901.151, 'text': "But we didn't exactly introduce all of these features ourselves.", 'start': 5897.41, 'duration': 3.741}, {'end': 5906.776, 'text': 'So it turns out in line 1 and line 2, we have one unfamiliar and one familiar line.', 'start': 5901.511, 'duration': 5.265}, {'end': 5910.5, 'text': 'Line 2 just gives us access to command line arguments, which we needed for resizing the bitmap.', 'start': 5906.836, 'duration': 3.664}, {'end': 5914.003, 'text': 'Line 1 is where a lot of the power is coming from.', 'start': 5910.96, 'duration': 3.043}, {'end': 5916.426, 'text': "It turns out there's a library in Python called pillow.", 'start': 5914.063, 'duration': 2.363}, {'end': 5919.408, 'text': 'that you can install by typing a certain command at your terminal.', 'start': 5916.846, 'duration': 2.562}, {'end': 5921.349, 'text': "It doesn't necessarily come with your Mac or PC.", 'start': 5919.428, 'duration': 1.921}, {'end': 5923.21, 'text': 'You have to download it and install it with a command.', 'start': 5921.369, 'duration': 1.841}, {'end': 5928.293, 'text': 'And then if you read its documentation, it will say, from pill, for pillow, import image.', 'start': 5923.65, 'duration': 4.643}, {'end': 5930.114, 'text': "Now, that's not a specific image.", 'start': 5928.633, 'duration': 1.481}], 'summary': 'Introduction to python coding, using the pillow library for image processing and resizing.', 'duration': 80.266, 'max_score': 5849.848, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU5849848.jpg'}, {'end': 5973.246, 'src': 'embed', 'start': 5946.164, 'weight': 6, 'content': [{'end': 5950.087, 'text': 'All right, if the length of argv is not 4, yell at the user with the usage.', 'start': 5946.164, 'duration': 3.923}, {'end': 5953.43, 'text': "And that's just if they don't cooperate by typing in as they should this.", 'start': 5950.107, 'duration': 3.323}, {'end': 5959.595, 'text': "It's a little more verbose now because we have Python and we have the file extension, but we could technically clean that up if we really wanted.", 'start': 5953.47, 'duration': 6.125}, {'end': 5962.998, 'text': "Line 7, 8, and 9, there's nothing really new there.", 'start': 5959.935, 'duration': 3.063}, {'end': 5966.12, 'text': "I'm just declaring three variables implicitly typed.", 'start': 5963.278, 'duration': 2.842}, {'end': 5968.142, 'text': "I don't have to bother saying int or string.", 'start': 5966.22, 'duration': 1.922}, {'end': 5973.246, 'text': "I'm accessing argv 1, 2, and 3, which is 1, 2, and 3.", 'start': 5968.522, 'duration': 4.724}], 'summary': 'Python script checks argv length and accesses values.', 'duration': 27.082, 'max_score': 5946.164, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU5946164.jpg'}, {'end': 6061.061, 'src': 'embed', 'start': 6034.671, 'weight': 7, 'content': [{'end': 6040.313, 'text': "So this is not just converting the user's input to the equivalent ASCII value, because that's not what we want.", 'start': 6034.671, 'duration': 5.642}, {'end': 6048.096, 'text': 'This int use here is actually converting it as via a2i, a function that you probably used a couple of weeks ago.', 'start': 6040.793, 'duration': 7.303}, {'end': 6050.177, 'text': "It's just named a little more succinctly.", 'start': 6048.416, 'duration': 1.761}, {'end': 6056.619, 'text': "There is a function via which you could convert a character or a string to its ASCII equivalent, but that's not what's going on here.", 'start': 6050.417, 'duration': 6.202}, {'end': 6061.061, 'text': 'It does the more intuitive, turn this into an integer without using a cryptically named function like a2i.', 'start': 6056.679, 'duration': 4.382}], 'summary': "The 'int use' function converts characters to integers via a2i, but more intuitively.", 'duration': 26.39, 'max_score': 6034.671, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU6034671.jpg'}, {'end': 6148.67, 'src': 'embed', 'start': 6121.982, 'weight': 8, 'content': [{'end': 6125.565, 'text': 'The original width times n, the original height times n.', 'start': 6121.982, 'duration': 3.583}, {'end': 6126.846, 'text': 'No padding manipulation.', 'start': 6125.565, 'duration': 1.281}, {'end': 6128.808, 'text': "That's all the responsibility of the library.", 'start': 6126.886, 'duration': 1.922}, {'end': 6130.89, 'text': 'Some other human dealt with all of that for us.', 'start': 6128.868, 'duration': 2.022}, {'end': 6136.316, 'text': 'And this last line, perhaps not surprisingly, saves the output image to that file name.', 'start': 6131.151, 'duration': 5.165}, {'end': 6140.561, 'text': 'So in just what 15 lines of code and fewer, if we get rid of some of the white space?', 'start': 6136.536, 'duration': 4.025}, {'end': 6144.425, 'text': 'can you implement the entirety of resize, but really focusing on the logic of the problem?', 'start': 6140.561, 'duration': 3.864}, {'end': 6145.867, 'text': 'I want to take an input from the user.', 'start': 6144.485, 'duration': 1.382}, {'end': 6147.569, 'text': 'I want to scale it up by a factor of n.', 'start': 6146.107, 'duration': 1.462}, {'end': 6148.67, 'text': 'And I want to save out the file.', 'start': 6147.569, 'duration': 1.101}], 'summary': 'Code implements image resize by a factor of n, output to file.', 'duration': 26.688, 'max_score': 6121.982, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU6121982.jpg'}], 'start': 5228.827, 'title': 'Python data structures, printing patterns, and image processing', 'summary': 'Covers hash tables and objects in python, printing patterns with loops and libraries, and python image processing in just 15 lines of code, focusing on image manipulation and ascii conversion.', 'chapters': [{'end': 5538.923, 'start': 5228.827, 'title': 'Python data structure', 'summary': 'Introduces the use of hash tables and objects in python to store and manipulate data, demonstrating how to create and use objects, iterate over them, and access their key-value pairs.', 'duration': 310.096, 'highlights': ['The chapter introduces the use of hash tables and objects in Python to store and manipulate data, demonstrating how to create and use objects, iterate over them, and access their key-value pairs.', 'Python allows for the creation of hash tables using curly brackets and key-value pairs, providing a more generalized data structure than a simple list of values.', 'The use of objects in Python enables the association of keys with values, allowing for more flexibility and readability in accessing and manipulating data.', 'The syntax for accessing the values of keys in an object or hash table in Python involves using square brackets and the key name, providing a convenient way to access specific data elements.']}, {'end': 5945.464, 'start': 5538.963, 'title': 'Printing patterns with python', 'summary': 'Discusses printing patterns using python, including printing question marks and hashes in different patterns, and utilizing loops and libraries for image processing.', 'duration': 406.501, 'highlights': ['Printing question marks in different patterns using Python, including using loops for improved design. This includes discussing printing question marks in different patterns using Python, including using loops for improved design.', 'Printing hashes in different patterns using Python and utilizing loops. The discussion covers printing hashes in different patterns using Python and utilizing loops.', 'Utilizing libraries for image processing in Python, such as the Pillow library. The transcript discusses utilizing libraries for image processing in Python, such as the Pillow library, and the process of downloading and installing it.']}, {'end': 6140.561, 'start': 5946.164, 'title': 'Python image processing summary', 'summary': 'Covers python image processing using argv, implicit variable declaration, error checking, and image manipulation in just 15 lines of code, focusing on converting input to ascii values and resizing the image.', 'duration': 194.397, 'highlights': ['The chapter covers Python image processing using argv, implicit variable declaration, error checking, and image manipulation in just 15 lines of code', 'The code demonstrates converting user input to ASCII values and the potential need for error checking if the user provides invalid input', 'The last few lines focus on using the image library to open, extract dimensions, resize, and save the output image, demonstrating the functionality built into the library']}], 'duration': 911.734, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU5228827.jpg', 'highlights': ['Covers hash tables and objects in Python, demonstrating how to create and use objects, iterate over them, and access their key-value pairs.', 'Python allows for the creation of hash tables using curly brackets and key-value pairs, providing a more generalized data structure than a simple list of values.', 'The use of objects in Python enables the association of keys with values, allowing for more flexibility and readability in accessing and manipulating data.', 'Printing question marks in different patterns using Python, including using loops for improved design.', 'Printing hashes in different patterns using Python and utilizing loops.', 'Utilizing libraries for image processing in Python, such as the Pillow library.', 'Covers Python image processing using argv, implicit variable declaration, error checking, and image manipulation in just 15 lines of code.', 'The code demonstrates converting user input to ASCII values and the potential need for error checking if the user provides invalid input.', 'The last few lines focus on using the image library to open, extract dimensions, resize, and save the output image, demonstrating the functionality built into the library.']}, {'end': 6725.596, 'segs': [{'end': 6277.203, 'src': 'embed', 'start': 6250.237, 'weight': 3, 'content': [{'end': 6255.138, 'text': 'All right, so this is the Python version of the distribution code for Speller for your dictionary file.', 'start': 6250.237, 'duration': 4.901}, {'end': 6255.878, 'text': 'So unload.', 'start': 6255.178, 'duration': 0.7}, {'end': 6259.459, 'text': "Also didn't take an argument, so that's something for us to do too.", 'start': 6256.439, 'duration': 3.02}, {'end': 6262.34, 'text': "So what's the gist of making a spell checker??", 'start': 6259.819, 'duration': 2.521}, {'end': 6267.941, 'text': 'You are loading words in your load function from a dictionary file and the goal is to load those somehow into memory.', 'start': 6262.42, 'duration': 5.521}, {'end': 6275.283, 'text': 'You had a design decision for the pset in C, where you could make a hash table or a try, or even a linked list or even an array, but odds are,', 'start': 6268.001, 'duration': 7.282}, {'end': 6277.203, 'text': 'the first of those two were probably more efficient.', 'start': 6275.283, 'duration': 1.92}], 'summary': 'Python speller distribution code loads words into memory efficiently using hash table or trie.', 'duration': 26.966, 'max_score': 6250.237, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU6250237.jpg'}, {'end': 6404.585, 'src': 'embed', 'start': 6359.166, 'weight': 4, 'content': [{'end': 6363.428, 'text': "Because in the file, technically, when you're reading in those words, every line ends with a backslash 0.", 'start': 6359.166, 'duration': 4.262}, {'end': 6364.289, 'text': "That's not part of the word.", 'start': 6363.428, 'duration': 0.861}, {'end': 6366.87, 'text': "So a minor correction there that I'm stripping off the line.", 'start': 6364.529, 'duration': 2.341}, {'end': 6367.71, 'text': "But that's it for load.", 'start': 6366.91, 'duration': 0.8}, {'end': 6380.624, 'text': 'How do I now check if a given word is in that set? Well, I can just say if word in words return true, else return false.', 'start': 6368.251, 'duration': 12.373}, {'end': 6382.185, 'text': 'Done with check.', 'start': 6381.065, 'duration': 1.12}, {'end': 6390.909, 'text': 'How do I return the size of this data structure? How about I just return the length of that structure, words, and then unload.', 'start': 6382.965, 'duration': 7.944}, {'end': 6392.59, 'text': "Heck, Python's doing this all for me.", 'start': 6391.009, 'duration': 1.581}, {'end': 6396.958, 'text': 'Done Let me shrink this.', 'start': 6392.73, 'duration': 4.228}, {'end': 6398.939, 'text': 'And you know what? This is a little verbose.', 'start': 6397.518, 'duration': 1.421}, {'end': 6400.281, 'text': "I don't actually need to do this.", 'start': 6399.06, 'duration': 1.221}, {'end': 6404.585, 'text': 'If else, I could just return word in words, and that will return a Boolean for me.', 'start': 6400.341, 'duration': 4.244}], 'summary': 'Reading in words with minor correction, checking word presence, and returning size of data structure in python.', 'duration': 45.419, 'max_score': 6359.166, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU6359166.jpg'}, {'end': 6583.825, 'src': 'embed', 'start': 6558.046, 'weight': 0, 'content': [{'end': 6562.611, 'text': "But what is clearly different, though? It's slower.", 'start': 6558.046, 'duration': 4.565}, {'end': 6564.672, 'text': 'So Python seems to be slower, right?', 'start': 6562.771, 'duration': 1.901}, {'end': 6568.995, 'text': 'It takes in total, if we just look at two numbers 1.55 seconds in Python.', 'start': 6564.732, 'duration': 4.263}, {'end': 6572.717, 'text': 'if you ignore the internet speed and just look at the code performance versus 0.9..', 'start': 6568.995, 'duration': 3.722}, {'end': 6576.66, 'text': "And so it's almost twice as slow as C.", 'start': 6572.717, 'duration': 3.943}, {'end': 6581.824, 'text': "So what's the takeaway there? Well, yes, it took me, you know, what, 10, 20, 30 seconds to write the code.", 'start': 6576.66, 'duration': 5.164}, {'end': 6583.825, 'text': "But it's taking me twice as long to run it.", 'start': 6582.044, 'duration': 1.781}], 'summary': 'Python code takes 1.55 sec vs 0.9 sec for c, making it almost twice as slow.', 'duration': 25.779, 'max_score': 6558.046, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU6558046.jpg'}, {'end': 6663.666, 'src': 'embed', 'start': 6633.704, 'weight': 1, 'content': [{'end': 6635.025, 'text': "And there's clearly a price with Python.", 'start': 6633.704, 'duration': 1.321}, {'end': 6637.127, 'text': "And it's not because Python's poorly implemented.", 'start': 6635.045, 'duration': 2.082}, {'end': 6643.652, 'text': "But what is the fundamental difference between the paradigm of programming in C versus in Python, as we've seen it today?", 'start': 6637.607, 'duration': 6.045}, {'end': 6645.554, 'text': "What's different??", 'start': 6644.913, 'duration': 0.641}, {'end': 6654.681, 'text': 'Yeah?, line by line, whereas C it essentially, if there are places it can optimize.', 'start': 6645.574, 'duration': 9.107}, {'end': 6657.721, 'text': 'DAVID MALAN, Indeed.', 'start': 6657.261, 'duration': 0.46}, {'end': 6658.502, 'text': 'And let me flip it around.', 'start': 6657.741, 'duration': 0.761}, {'end': 6660.723, 'text': "So with C, you're compiling down to zeros and ones.", 'start': 6658.522, 'duration': 2.201}, {'end': 6662.205, 'text': 'And that compiler is super smart.', 'start': 6660.743, 'duration': 1.462}, {'end': 6663.666, 'text': "And it's going to move things around in memory.", 'start': 6662.245, 'duration': 1.421}], 'summary': 'Python and c differ in their programming paradigms and optimization capabilities.', 'duration': 29.962, 'max_score': 6633.704, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU6633704.jpg'}], 'start': 6140.561, 'title': 'Implementing resize, python speller example, and c vs python performance', 'summary': 'Discusses the implementation of resize and a python speller example, covering word loading, existence checking, and data structure size. it also compares the performance of c and python, with the spell check program taking 1.55 seconds in python and 0.9 seconds in c, highlighting trade-offs between developer time and efficiency.', 'chapters': [{'end': 6404.585, 'start': 6140.561, 'title': 'Implementing resize and python speller example', 'summary': 'Discusses implementing the entirety of resize and a python speller example, detailing the process of loading words, checking word existence, and returning the size of the data structure.', 'duration': 264.024, 'highlights': ['The chapter discusses the process of loading words into a dictionary data structure in Python, iterating over lines in a file, adding words to the data structure, and returning true upon successful completion. N/A', "The chapter explains the method for checking the existence of a given word in the set, detailing the use of 'if word in words' to return true or false. N/A", "The chapter outlines the process of returning the size of the data structure by utilizing the 'length' function in Python. N/A"]}, {'end': 6725.596, 'start': 6404.865, 'title': 'C vs python performance', 'summary': 'Highlights the performance difference between c and python, showcasing that running the spell check program in python took 1.55 seconds compared to 0.9 seconds in c, emphasizing the trade-offs between developer time and program efficiency.', 'duration': 320.731, 'highlights': ['Running the spell check program in Python took 1.55 seconds compared to 0.9 seconds in C, showcasing the significant performance difference between the two languages. The spell check program took 1.55 seconds in Python compared to 0.9 seconds in C, indicating a significant performance gap between the two languages.', 'Emphasizing the trade-offs between developer time and program efficiency, the chapter illustrates that while Python allows for quicker coding, it may result in slower program execution compared to C. The chapter emphasizes the trade-offs between developer time and program efficiency, showcasing that while Python enables quicker coding, it may result in slower program execution compared to C.', 'Highlighting the differences between C and Python, the chapter underscores that while Python allows for faster coding, C runs programs more efficiently, making it suitable for large data sets and resource optimization. The chapter highlights the differences between C and Python, emphasizing that while Python allows for faster coding, C runs programs more efficiently, making it suitable for large data sets and resource optimization.']}], 'duration': 585.035, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/hnDU1G9hWqU/pics/hnDU1G9hWqU6140561.jpg', 'highlights': ['The spell check program took 1.55 seconds in Python compared to 0.9 seconds in C, indicating a significant performance gap between the two languages.', 'The chapter emphasizes the trade-offs between developer time and program efficiency, showcasing that while Python enables quicker coding, it may result in slower program execution compared to C.', 'The chapter highlights the differences between C and Python, emphasizing that while Python allows for faster coding, C runs programs more efficiently, making it suitable for large data sets and resource optimization.', 'The chapter discusses the process of loading words into a dictionary data structure in Python, iterating over lines in a file, adding words to the data structure, and returning true upon successful completion.', "The chapter explains the method for checking the existence of a given word in the set, detailing the use of 'if word in words' to return true or false.", "The chapter outlines the process of returning the size of the data structure by utilizing the 'length' function in Python."]}], 'highlights': ['The spell check program took 1.55 seconds in Python compared to 0.9 seconds in C, indicating a significant performance gap between the two languages.', "Python's for loop simplifies the iteration process over arrays and strings by eliminating the need for explicit index manipulation, providing a more concise and readable code.", "Python's lists, being resizable, allow for operations such as appending elements and conditional list operations with a syntax that reads more like English, simplifying the process of working with lists.", 'Python allows for the swapping of variables without the need for a temporary variable, streamlining the process of variable swapping.', 'Python eliminates semicolons and curly braces, making its syntax more concise compared to C and JavaScript.', "Python eliminates syntactic overhead, making it easier to write simple programs, like printing 'hello world', without the need for main function, header files, semicolons, or explicit type definitions.", "The concept of requesting specific web pages using the HTTP protocol is discussed, emphasizing the server's role in responding to such requests.", 'The HTTP protocol as the command inside the envelope, used by the server to determine its response to a request for information.', "The default file name on a server for a web page is 'index.html', and the server response code 'HTTP 200' indicates 'OK'.", 'The use of numeric IP addresses and port numbers, like 80 or 443 for HTTP or HTTPS, is highlighted as unique identifiers for computers and services.']}