MORE CHAT CODING PYTHON! - CS50 Live, EP. 59

CS50 · Intermediate ·💻 AI-Assisted Coding ·7y ago

Key Takeaways

Involves live-coding in Python, where the chat participates in writing code for a working script

Full Transcript

all right hello world this is cs50 live my name is Colton Ogden cs50 if you're unfamiliar for watching on YouTube or whatnot is Harvard's intro to computer science top at David Malin my name is Colton Ogden and I sort of lead this stream we do a whole bunch of different things we have guest people come in Nick Wong is a recurrent guest often each week but we've had many other people that work with cs50 including David I think Nick was on in the last stream but we do a game programming for example which is a lot of what I do we do things we do website development which we've done this week or this year we've done the HTML Javascript CSS all that kind of stuff and one of the more recent threads that we've been doing and which has been kind of fun and kind of bi-directional a little bit experimental a little bit chaotic is programming using only what people in the chat actually use as the lines that make up the script in hello Jason ji from Greece drew key nice collage and surreal CS but yeah it's been pretty fun the last couple times we've done this we've done I believe this is the third iteration of this experiment the first time we did this we was just pure chaos it was just kind of like people could write whatever lines of code they wanted to and it was fun it was a good time and we decided after that to make a rectangle sort of script similar in spirit to mario the mario pset from cs50 except a chuka niece is asking is there a bot or not yet unfortunately haven't at a time haven't had time to write a bot yet so I will still be I will still be taking mr. Destructo at emojis in the chat but no this is the second thing we made was a box thing where you could actually enter the number or the size of the rectangle that you wanted to write the size of the square rather in this in the command line prompt and actually write though actually draw the full square which is pretty cool last time we did project Euler examples where and I have it up here we did a multiples of three and five sort of problem and then the even Fibonacci numbers which I thought was pretty fun pretty entertaining it was a nice way of setting goals for us and solving fairly interesting problems and I kind of flexible as to where we go today so this experiment has been kind of interesting I think there are directions we could go in the future to make it even more interesting and then we could maybe do game development or something like that using Lua which would be a lot of fun which we've done on the stream before but I'm gonna kind of I guess maybe take some eggs take some suggestions as to what we might want to do we decided to pub the last stream on this as a sort of library excuse me the library use case example in which we would actually allow people to install using pip libraries that we can use in the in the scripts to do things I'm a little more specialized but I think we might need a little bit of coordination actually decide which libraries we're gonna use and for what purposes and so I'll leave it up to the chats well we'll take ideas we'll see what's worth it we'll see what's fun well car shake what's today's topic about today we're just gonna be coding in Python together on the screen so I'm gonna switch to my computer and this is what we ended up writing last time so this is the script that actually does the even-even Fibonacci numbers or is this the one that sums it I don't actually remember no this is the sum of the even value Fibonacci numbers up to but not including I believe four million and as you can see it's kind of chaotic I mean we have a comment for each and every person who actually contributed to the script Somu 9 : Poros DM SMTP etc etc the script got kind of lengthy and here at the bottom we had a queue of the folks that were going to add new lines of code to the script after you know before we had finished writing it and yeah it was good stuff who talks we're in first time watching this live gonna pull an all-nighter today oh man that's that's exciting is it really late where you are is that what you say that but yeah how late am i Babic now we just started weird we are just beginning we haven't written a single line of code and I think if we want to start the queue up or if people actually want to start suggesting ideas for what we want to code today I mean Kuakini said always up for Euler seems to go from easiest to hardest and it's useful in Amethi logic kind of deal and I agree with that I think it's interesting I think it'd be cool since we did so much of that on the last stream to think about other ideas maybe if we could go in other directions loner King tonight from India why Sara eight six three four says hello hello and tehsil Rx is not late enough true we only just started a four minutes ago if if that much but yeah let's think about what about one a code today and the sort of way that we do this is kind of ad hoc but if you would like to participate in the queue of suggesting lines of code or actually well not even suggesting just literally coding lines of code all you do is write this in the chat the three robots three mister Destructoid's that's my way of visually seeing that you want to contribute to the script if I see that I'm gonna add you to this queue and this is a queue from last time but we're gonna discard it because a lot of folks might not be here anymore I'll save that and actually then I create a brand new repo for this I did for the last time so I'm gonna do this right now up front chat codes Python 3 and this will be our new project so I'm just gonna click and drag this over to vs code this is the editor that I'm using I'm using vs code and it's a really awesome editor I highly recommend using it makes it very easy to do a lot of cool things a lot of great themes that are really easy to build a lot of good extensions very nice quality of life editor similar in features to atom and sublime text and it looks like loaner Kington is the very first person to suggest a a line of code or who would like to get added to the queue to create a line of code chuga nice asks can we find a code python project on github and try to add to it that would be very hard to do in real time because of the nature of just approving all the pull requests and the fact that they're sort of coming in asynchronously and the merging would be kind of chaotic yeah I don't know I don't know if that's the right vehicle for this but having a live way of getting it to work will be interesting so we can maybe think about ways to do it in the future and I still have an idea in my mind about setting up a script a node server that actually takes in data from the chat and integrates it into a script on my computer itself but there are security issues with that and similar issues what you would get with github with merging and something like that Pietro Cooney says I want to do something useful anyone have any needs we can program something for hopefully somebody has an awesome problem to solve loaner kington I've added you to the queue I'm gonna add myself to the queue as well I'm gonna start doing this more consistently just so that I actually have a little bit more of a participatory role in what we're coding because I actually enjoyed doing that last time I thought that was fun but yeah if anybody has suggestions before we start this is the time we'll spend not too long on deciding this project Euler is our fallback but if we can think of something a little bit different more unique novel interesting than project Euler then we will definitely pursue that so rule says just curious what's with the cs50 cat in the logo that comes from a long time ago when David was teaching the class and wanted to use the memes at the time in the problem sets to make them a little bit more entertaining and also just the material online more generally and it's the I Can Has Cheezburger cat which was a meme I think around the late 2000s but we've kept it just as a sort of call back to the past if you will and we still use it from time to actually we still use it for a lot of our materials it's obviously still our logo on Twitch so which is one of our current platforms are really using oh I just swallowed incorrectly I'm doing a low good to see you unknown boy can we create a new library at Python that's very ambitious undone blank and also extremely generic it's an old meme but it checks out you said bad Beijing yeah it does so works you're just keeping it relevant you know we try can we build something like a web app or a mobile app says Babic that might be a little bit too ambitious let's just let's stay to Python for now maybe a web up in the future just because we advertise this as a Python stream we want it we want to maybe make it keep it keep it in the realm of Python and probably not something too specific although libraries are allowed you can import libraries if you want to cure you hi good to see you preserve all I've got a flask started you guys can play in again since we advertised this as just a Python stream I don't think going in too deep in there Alma flies because the nicest thing to do to our audience but I think in the future if we have a chat codes a web app from scratch a stream which maybe we could two weeks from now or something like that then I think that would be great actually can we try printing a square spiral do you have a link to where I can see something like that kiddies how about a mathematics library these are very is a very bold and lofty goals I mean I admire it but I want to learn how to use create a mobile app using kivi hey Colton and chat what is this about today today we are going to create Python script from scratch and we're going to do it only using what the chat codes in the like what twitch chat actually types in the in the chat but there's a queue so if you want to get added to the queue if you're new watching this and you don't know what's going on cows and bulls not sure what that's a reference to whoops if you would like to participate just type this in the chat I will see that and I will add you to the queue let me see what this is oh this is cool I don't even know how I would do this I would need to spend quite a good amount of time I would say yeah because I've never even done something like this I would need to think about it but I would I would say I mean I could use the stack overflow code obviously getting something like this code something that we could ideally finished in two hours and have a reasonable shot at would be ideal if we were doing this I think for eight hours I think that might be a good enough good enough goal a simple module where you can add a bunch of functions from factorial to perhaps Euclidean distance you know simple stuff Babic wants to create data structures Babic a lot of the people watching this dream might not even know what those things are let alone how to implement them we need to think we need a step take a step back from the super lofty stuff because we only have to remember we only have two hours so this needs to be something that we can feasibly try to accomplish in an hour or two such that we don't leave sort of at the end and have nothing to show for our time you know because it might be two weeks before we have another one of these streams these chat coding streams cows and bulls is the master mind game I like that one a Pomodoro clock you see that actually that is getting closer to the realm of feasibility Andre so that I'm I would almost I'm almost down for that but if anybody has other ideas please please please chime in let's see cows and bulls is that what Braveheart said cows and bulls mastermind bulls and cows old code-breaking mind or paper-and-pencil game for tumour players predating the commercially marketed board game mastermind interesting trying to reveal a secret number oh and there's one forwards - oh I got you oh it tells you how many you got right how many got wrong okay that's interesting still I think a bit lofty something object-oriented bad like a lot of these people again don't know what classes or objects are you have to take that into consideration is this somebody's birthday we can print a birthday cake Oh that'd be cool actually you gotta stop working on it every 15 minutes yeah that's that's true so I'm gonna take a break remove my name sure no problem Pomodoro is sounding pretty cool do we have other people that are down for Pomodoro it's pretty easy to know the Pomodoro is for the people who don't know what that is Pomodoro there's a Pomodoro Technique as well time management method SOTA Pomodoro is as the hello goodness you a Pomodoro Pomodoro is a little I don't even know what it actually is at the pump oh it's a Italian word for tomato there you go it's a tomato shaped timer and what it essentially is is you turn it to a how much time you want it to tick it's a it's just a almost like an alarm clock or just stopwatch and after that amount of time has passed you take a break from whatever you're doing the goal is that when the Pomodoro is currently ticking you spend that time actively focusing on something that you want to do if it's a task at work or if it's something else and it's just nice because you kind of segment your day into chunks of time and chunks of rest you take usually it's 25 minutes of work and 5 minutes of rest as it even says here in the article traditionally 25 minutes in length separated by short breaks so what we could do is we can make a timer at Pomodoro timer that maybe we could maybe make it work for just a few seconds and then say now take a break and then then it'll take a break for a few seconds and then it'll say okay now get back to work and then take a break and then get back to work and then so on and so forth so I think it's a doable problem to solve but we'll see we'll see what we can do sure we can 21 says lots of people today I'm actually not looking at the number of people tuned in to twitch but um we'll see how many people are on Twitter today Oh 160 okay well hello everybody welcome to the welcome to cs50 live where we code things live from scratch let's see what we can do does it run continuously Vernie oh well that's kind of up to you I think the goal is that we create a idea so the Pomodoro idea and then the chat it's kind of up to the chat as to how we actually implement it what that actually means but let's assume that we're gonna start with the goal of a Pomodoro and I will just write a vague general sort of description of what this should be so should act as a timer for a short period of time punctuated by short break periods that's really all a Pomodoro is and I think that's it so if you would like to participate in this we have a goal now so we're gonna create a Pomodoro script it's gonna be command line script and we'll see what we can go from here so if you'd like to participate if you're watching and you don't know how this works three and Andre is the first person you need three of those robots so if you're looking at the twitch chat three mister Destructoid's if you're watching this on YouTube or Facebook I will not see it so you need to go to the twitch TV slash cs50.tv and type in three mister Destructoid emojis and I will know you want to participate in the chat so let's create our queue here I already put my name in there just because I enjoy being part of it too in my small way Indra ready 5 Percival 13 12 whoops Braveheart Oh Oh - - and and when you write the code mention line number says true key nice true yeah if you write your code it helps me a tremendous deal if you tell me which line you want to write your code on because I often especially in Python whether you write on one line or another whether it's indented or not it makes a tremendous difference so do tell me where you want your code written and if you want to indent it or not that makes it very easy for me to plant your code makes things more efficient maybe six six four hello good to see you Konami should mention a format for contributing oh yeah I mean that's a effectively that's all really just the your line number whether you want it indented and the code itself that's that's effectively what we need then truká nice I got you as well trucha nice if you could just let me know if I miss anybody I will do my best to keep on track keep on top of everybody keep track of all submissions but if I miss somebody I apologize there's sometimes a lot of chat it's easy to miss things I will I will start actually for the first time this is this is kind of crazy this is a lot of weight on my shoulders but um I'm an import time because it's a script about time management I feel like the time module might serve us a good use case in the near future I'm a chatbot I gotcha I appreciate chicken ease you don't have to if you don't want to I appreciate your contributions but this is my contribution to the script import time the time module in Python lets us do all kinds of things and if you the documentation for it it's there's a lot of documentation for it on the Python Doc's NaCl Eric I got you so that is my contribution I'm going to go ahead and then the thing that I like to do is write whoever contributed that line give them a comment so here we can see that I created this line and this lets us place the blame on people this is effectively the same thing as what's called a git blame which is a lot if your software project breaks on github you can look at the person who actually broke the code by looking at each line and seeing who contributed that line and you know it's it could be good stuff it could be good stuff SM Ryan I will add you to the list SM Ryan more pressure so Andre you're the one who contributed this idea of creating the Pomodoro script let's get some feedback from you Bella good to see you you just start you just came as we came as we just started so no no worries there and thanks to all of the people who are following I missed the names I'll read them off right now thank you very much to Matt Mac for pg9 this is easy for SH events like I sure how to pronounce that one sends no one a Tuukka attacker DOS Apollo I'm apologizing Bank whisper I definitely mispronounced that one but let's be honest thank you new Mars Alabama and Grayson Slade thank you very much those last few were a little bit easier to pronounce do you submit actual code or pseudo code actual code this needs to be actual code I will write is whatever you type for better or worse in the in the in the script and is this affiliated with the Harvard cs50 course this is affiliated with the harvest a safety course David teaches this unity course I will I'm David this is a new initiative on our part David actually is on stream often and next week might even be on stream he was on stream last week doing a code review so that one was pretty cool but this is sort of a branch off of cs50 where we do a little bit more deep dives into cool things and experiments and all that fun stuff so Andre Andre Andre Andre Olaf from canarian Islands equal licks thank you very much for tuning in hello hola as well blue penguin how about we make a Caesar cipher eventually maybe but that would kind of break the academic dishonesty for cs50 the guidelines so we might not be able to do something like that that's directly related to a cs50 pset we probably can't program on camera that would it would cause issues for me and for many people so guidelines are that we should not have code solutions for problems that's existing in the world especially I mean there are some that exists but we cannot procure them but the exact formal guidelines I do not have handy but they are in the syllabus I believe for su su you can go to the College website start time equals time see time okay this is Andrey start time equals time see time courtesy of Andrey Petelin in red is now your turn time gutsy time what is time see time I'm actually not entirely sure what that function does didn't see here convert a time expressed in seconds since the epoch to a string representing the local time okay if sex is not provided or none the current time as returned by time is used okay cool so whatever the current time is in seconds cool sounds great sounds like a good contribution to the script we'll probably will need that at some point or other injury Eddie says 9/9 line import cs50 I don't have the cs50 library installed I don't think fun fact not on this account however we do have PIP so if somebody wants to suggest a pip install of cs50 and by all means actually what I could probably do is just import it if someone imports the library we could do that I'm gonna set up a virtual environment in that case and also shout out to David J mailing in the chat teaches cs50 any of the folks here that aren't unfamiliar with what cs50 is he is the instructor and he was on last week he did a code review and he might be on next week we'll see put some pressure on him but uh somebody wanted to import the CSV library so in order to do that we need to actually use pip for that hip is the Python package installer I'm not sure what pip actually stands for I remember offhand hey Colton I've been in love with the series ever since your first episode since I heard that you still don't have a bot I would love to offer to make one for you if you're interested I would send you the source code of a prototype in a few days says bézier Nile let me think on that busy Nile I don't want to proactively I don't want to spend too much of your time depending on where this sub series of the of this stream goes right we could because I know it's gonna be at least a couple weeks before we even do it so let me just think before I say definitely do that very much appreciate your offer I think that's incredibly generous of you but in respect of your time I do not want to I do not want to have you do something and then have it not be used if that makes sense and also the spec might change and then we might need changes from it and I'd also don't want to incur a major time penalty on your behalf but I will I will definitely keep it in mind I appreciate the offer very much very generous do note that see time actually gives time in seconds since the epoch you subtract from a time from B time to get the time difference I see what I'm doing is doing Andres Andres given the chat a little bit of wisdom trying to get a little bit of Direction going and say stream want to follow on and write the code by notepad plus plus won't open blue penguin blue penguin I would suggest looking into vs code it's a great editor I think better than notepad plus plus they notepad plus plus is is okay it's what I started on many many years ago but we didn't have things like vs code and sublime and Adam back in the day so look at the s code I think it's an awesome editor pimps notes for Pitt missiles packages all right it's a recursive acronym but yeah that's true could you add the podcast download links to the YouTube hits podcast download links to the youtube vids do we not already have those in the youtube vids I'm pretty sure we already do if I'm not mistaken but I'll double-check that I added the YouTube I added the podcast download to episode 0 and I'm pretty sure episode 1 it's like I'm not entirely sure what you're referring to is if you looked in the description look in the description and let me know what's in there Rahul says I have the S code it's great it is indeed a great editor I'm getting distracted I apologize so let's go up to the new director I created which was check codes Python 3 and we happen to actually be coding in Python 3 today which is a coincidence but completely unrelated so this I'm going to do some fun stuff I'm going to create a virtual environment this is the command you need to run to create a virtual environment in Python 3 it uses the module VN and it creates a virtual environment called VN in my current directory what you want to do a virtual environment is a private installation not private it's a localized installation of Python that you can use to install separate from your system installation so if I want to have a project that has specific dependencies on specific libraries and started this almost sandbox you know in a sense in that way then you can use VN to do that and in Python 2 of the D module is called virtual end did the same exact thing now if I do source then then activate so it created a new folder in this directory so if ILS you'll see that there's now a V env virtual end folder in this directory and you can actually see it in vs code now it's right here in which you see a bin and bin actually has this thing called activate you notice has his own version of pip and Python as well there's all part of what V and as a creates a virtual environment with a complete Python installation so this allows me to install whatever libraries we want to and it won't apply to my whole system it'll just apply to this installation Python in this folder so what I can do now is I can say source then then activate and now you'll see that in my command prompt to have this little in parentheses the end thing this tells me that I'm using the installation of Python located at VM as opposed to my system installation so now if I pip install cs50 this should work looks like it's indeed working comes with sequel alchemy which takes up the larger portion of the time of the installation now if I go to python type python 3 again this is using the vm version of python I can do import cs50 whoops not cs50 9 import cs50 and it works it just it just it now is part of my local installation it's not applied to my system but it is applied to this sub sort of area and thanks so much for all the people following there's a tremendous number of people following today let me shout out all those folks so cool inspired Rahul Mario Thunder o7 1 Skywalker pro matix 20 6 7 8 9 Omar Hassan II 95 and riff GG well played thank you very much for the follows so is there a podcast playlist let's see s for the YouTube channel there is a podcast playlist to the cs50 YouTube channel no links to the CDN for episode 1 I don't think we intentionally did put links to the CDN for that but we can add that if needed benzyl says no worries about my time much appreciated Benzino let me think on that and I will I'll definitely get back to you how about we make a game that way there is no solution already created how about I make a game maybe on a future stream I really do in a future stream want to make a game because I think the visual sign of that would be very fascinating I think we would do that in love because I could help a lot with that with actually steering the chat if need be and provide commentary on what we're doing right what we're doing wrong it would be a little bit more difficult to do that in Python because I'm not as familiar with the Python gaming libraries like Pi game I've used it a long time ago but not to the extent that I've used love so I'm not entirely sure about that Thunder of 71 Rob Morrow James Koda we have so many people in the chat today and thanks all the people that are following iTunes Google podcast SoundCloud Spotify link today but no direct download links to the CDN okay that's a good point I will week we can I think we can do that I think we can do that Colton do you think it's better to finish the cs50 before starting the GD 50 or it's alright if I do them simultaneously I would advocate finishing cs50 first GD 50 is a lot of work and it does presume that you have knowledge of how to code we take an object-oriented programming approach in GD 50 and we do a lot of coding there the projects are very large granted you are provided with most of the source code the boilerplate to add your own features but having the chop section navigate the code and solve problems it's gonna help you tremendously you will have a harder time if you do not have some base level of programming knowledge that said you could probably do at least the first couple problem sets in Gd 50 without too much difficulty if you are somewhat fluent in programming some kind of language but I advocate for finishing cs50 first cs50 module or packaged cs50 is a I guess it would be both probably but it's a library it's a I think that technically considered both it's a module deployed as a package and it's a library it's all of these things but it's hosted online and it's got basically a bunch of helper functions embedded into it I'm thinking a text-based game oh we did that blue penguin that was our first experiment with this actually a few streams back Jesus the schedule is in Hindi oh that must be that must be your settings for for twitch and yeah so now we've imported cs50 so I apologize for that long winding way here let's prime factorize an absurd number yes that'll take no time at all so Andre did this and then Indra ready set import cs50 we've imported cs50 and we went over the process of how to actually set up a local virtual environment to do the if we want to import whatever arbitrary libraries so we now have the cs50 functions at our disposal things like getstring etc and we'll see where we go from there so first of all 1312 it is your turn and if anybody wants to contribute to the script here if anybody would like to add a nother while one on line 12 well that's a great start personal thank you so much for your awesome contribution if anybody wants to code and wants to contribute their lines just go ahead and type in the three robots in the chat and that tells me that you want to be added to the queue of names like you see right here at the bottom so per serve all set on line one add a wild one so I will go ahead and do that we'll humor personal again this is whatever the chat wants to program for better or worse and in this particular instance it's for worse so we'll see if we'll see how much we get hijacked today by by folks like Percival and he wants to add it back to the end which I'm happy to do this is a this is your world chat and I'm just a I'm just a messenger so we'll see how we do this you can't put a while before import savings can you believe you can in fact line 12 Oh on line 12 I apologize I thought sorry I got that mixed up there we go so Braveheart Oh Oh - - it is your turn at echod attack adieu Sao Paulo James coder wants to get added to the to the list it's my pleasure bad Bayesian wants to get added to list my pleasure that is not the right syntax and that Jukka nice is doing me an awesome service by pinging folks in the chat shout-out to trucha nice for their help in getting us sort of streamlined in this process it's fairly organic and it's bi-directional at times a little messy but it's fun I think it's engaging hopefully people are entertained by it but Braveheart Oh - - it is indeed your turn so let's see what you have are we gonna fix what Percival 1312 has set us up for or are we going to further our destiny down into the depths of chaos Unchained Goose just found you from the subreddit what are we making YouTube podcast you're not in a playlist I'm pretty certain we haven't added them to a playlist unless the playlist is not public which is actually possible I'm realizing now what are we making we are making a Pomodoro so here's the description so a Pomodoro if anybody is unfamiliar is a tomato timer it looks like this whoa that's really all the goal is and it's kind of up to the chat as to how we actually implement it but we'll see what we do Braveheart is saying they have to bow out that's totally fine appreciate your participation in any case Braveheart thank you for tuning in lay OGG is now your turn so the Pomodoro is just a timer you turn it it gives you a certain amount of minutes that during which you're supposed to kind of focus on doing something and after the Pomodoro timer has run out you're supposed to take a break and this is supposed to kind of help your brain balance work and rest a little bit more systematically and it's something that a lot of people swear by pretty famous can I change number 11 - time time absolutely yeah you can you can make amendments so for anybody unfamiliar we allow proposing amendments so in this case one a AAG actually that's one not Laye AAG one a odd proposed that we changed line 11 instead of time dot c time to time time so we absolutely can do that small changes are allowed large changes such as deleting lines or commenting out lines are not allowed because that would essentially erase the work that other folks have done the way that we want to structure this is such that we keep the work that other people have done but using programmatic techniques we can circumvent bad behavior if we need to right and it's an exercise in how to actually use the language to get around issues but yes thanks to Chu Cadiz if you want to contribute to the Python code right mr. Destructoid three times and when you write it mention line number mention whether you want indentation it helps me a great deal when we actually put together the code so thank you for your contribution 1a OGG chuka nice it is now your turn the one the only the true can ease and you are allowed to indent one line actually we talked about this in the last stream and it was that right now you're kind of allowed to indent an entire block of code so what I'm thinking is indentations have to exist in their own separate as their own separate requests to indent something or not so we can't actually right you can't actually indent an entire block by putting a while above it for example you could put a while at the very top but indenting all the lines below it we have to be a separate action so I think it's a little bit more fair so on line 13 print start time done courtesy of the trucha nice oh wait was that oh wait sorry that's not line 13 I apologize line 13 is roughly here I will try to keep the code kind of nicely styled just see if it gets a little unwieldy at times last qeq you have been added and the blue penguin nine you have been added and sir rule CS you have been added can it be a part of its success bucks absolutely but you have to write three mr. Destructoid robots in the chat I will I will consider that a since you explicitly added it just said it I will add it but it I might miss I might miss seeing the robots which is why are a miss seeing you say add me to the chat which is why we do the robots I want to make 100% sure that I see every request and it just is it pops out super super easily for me to visually see it okay NaCl Eric salt Eric it's your turn what have you got for us s MRI on SM Ryan it's not quite your turn but it's coming it's coming I realize they misspelled your name mage drew fought it's been a while since I've seen that name in the chat I'm good to see you there are many ways to indent and people tend to use four lines indentation yeah we're just doing the default vs code which is four spaces I think but it's tabs that get converted into spaces have to focus on something for 25 minutes why not use live share for vs code that would get incredibly crazy and also I would have to look a little bit further into the security of live share I've used it a couple times in cases that I knew I was safe like programming people I trusted but putting it on the internet I'm not sure if that's a smart thing to do please run the program want to see what prints out sure I can do that it's not gonna print anything because it's broken currently but we can type Python 3 script 1 you'll see that there's a end of file error while parsing the script line 28 I will leave it up to the chat to decide maybe why there's an error why there's a bug but there is a bug why don't we just sleep for the set time hey there's an idea oh did NaCl write their code yep line 13 break time is equal to or get the value of input length of break okay courtesy of nacl Eric thank you very much Eric SM Ryan I know that you proposed your line earlier while it is empty yes broiled victory in Porto s fall 200 s not fork there we go crumpets here there we go crumpets here thank you very much okay so SM Ryan what is your what is your you had a suggestion okay line 14 modified working time working time is equal to input length of work and if you're talking about this line that's a bit too different from what Kenny said I think to to allow an amendment on that world victory what's happening is you type three mister Destructoid's in the chat and you get to add a line of code so what we're trying to create is a Pomodoro timer so thanks to success bucks for typing that in the chat the Pomodoro Technique it's basically just a timer runs for X number of time and then gives you a break for X number of time usually the break is a much smaller amount of time than the actual work time and it's a way just of systematically dividing up your day into chunks that you can solve and we're doing that at the command line seems like a feasible thing to do within a time that we have allowed to us a lot of people had a lot of loftier goals that they proposed earlier in the chat but I feared we would not have enough time to finish set goals like creating entire libraries Ida nothing that's feasible especially in this manner in a two-hour period of time but I appreciate the ambition it means a lot I feel it and I appreciate it okay so confirm SM Ryan do you want to add that line here where my empty cursor is working time as input like the working time okay cool length of working time and now we have to indent all of the comments here and make sure we properly credit SM Arai on for their awesome contribution Percival 1312 the trolls it is now your turn again let's see how much more troll we can get and Rahul Morrow wanted to be added did I add you to the end I did and then also Pocoyo in 10 so not sure if I'm pronouncing that correctly chuka nice Omar Hassan II and a lot of folks wanting to contribute which is great a lot of new names I love it keep it coming Omar has me 95 are we gonna use the standard Pomodoro that with 3 completed Pomodoro's will get more break time we are doing whatever the chat wants to do now if you try to fork about me I will not allow malicious code in the script anything that will compromise my system but aside from that pretty much everything is fair game just nothing that would be a security risk and ideally nothing that creates files either we will I will probably not allow the creation of files or the or connecting to remote locations anything like that it needs to be secure stuff on my machine so first of all did you add a did you add a line of code I don't think so true candies just rang them po kayo intent so in English would be heavy poke I got it makes sense can you modify it please working time is equal to the input length of working time oh sorry did I miss the : I did my apologies my apologies ok depot ok I got you or diba Lok now try to pronounce that Andre is back in there very happy to see we have a lot of good actors today we might actually see this blossom into a completed program before the end of the script if all goes well assuming that percival 30 I mean really if first of all 13 12 is no longer in the chat we have a better chance because it's Percival's goal to compromise this script could change the wild to be something like while time is greater than one too many good actors say no more nacl Eric oh man I shouldn't have said anything I'm spurring the spurring the trolls key please got a comment each line of code can you please add a comment to each line of code well that's essentially what these are are these comments that deal with the names of the folks that actually contributed it I think if we added an individual comment each line of code currently it would be a little hard to read eventually also it's not always clear what to comment because a lot of this is kind of crazy okay so line 19 indent if start time plus work time is equal to time dot time okay if start time plus work time is equal to time dot time and actually you just have that you don't even have a colon on that so I'm going to do that and we're gonna add first of all 1312 J s coder with a colon on the end okay okay got you okay you saved yourself prison I was almost too late it was almost too late I have to go for now but I'll check back later to see how this goes says one a ugh all right J s coder it's your turn now see what we got what do we have from you are we going to see we have 200 people watching right now holy cannoli that's awesome thanks to all the people that are watching it's pretty cool if you're watching and you're not already tuning it or not already participating definitely get in there have some fun and if not I guess maybe watch and learn a few things about Python or maybe not learn anything about Python depending on how the chat actually behaves today we'll see if see if people behave nicely and actually try to to make this script work even the nefarious stuff ends up ends up teaching us a thing or two sometimes though : poor us forgot about the stream today just tuned in as leety wants to contribute as ly it makes me so happy to see you contributing makes me tremendously happy to see you contributing Jay s coda though we are waiting on you it is your turn while one is actually great we want the timer to be reset after the time is 25 minutes right yeah that's true a while loop in this case actually is kind and nice my initial thought was that we were just gonna try to get into an infinite loop of some kind with a wild one but uh no turns out first of all thirteen was the hero in disguise is the hero that we don't deserve but a Jay s coder we are waiting for you walks rooks I am not good at Python is that okay if I join it is beyond okay you are more than welcome all are welcome to join where our goal is to have fun and honestly learn a couple things if you're unfamiliar with Python if you're brand new this is a great way to learn seeing things break is essentially how you learn how to program or seeing things break and fixing them print you need to break take a break prynt you need to take a break and then break from the loop now we can't do multi-line lines of code so what Jay s coder said was print this you need to take a break and then break from the loop but we can't actually do that that would require me to do something like this breaking from the loop can only do one line per superb per text submission chat submission otherwise people would submit crazy blocks of code and it would get a little bit unfair I think so bad beige in your turn bad Bayesian it's all on you and again if you're unfamiliar with the system trucha niece has kindly pointed it out if you want to contribute to the python code if you want to write a line if you want to get added to this queue of folks here just type 3mr Destructoid emojis in the chat and we will gladly take your submission for better or worse hopefully it's for all good intents and purposes and not for evil intents and purposes but you know evil intents and purposes are welcome as well it can be fun it can be entertaining sometimes so bad Bayesian want to be added to the end whoops I spelled that wrong I think and on line 10 import web browser okay now now bad Bayesian uh-huh I'm just gonna warn you there there are certain things that we'll accept with this library and there are certain things that I will not accept that are inappropriate for the stream so I kindly implore everybody who is watching this to please keep this kid friendly as much as possible so bad Bayesian thank you for your contribution the last keck has asked to be added to the end of the queue and on line seven says quit okay on line seven add quit that is amazing a great contribution from the last kak thank you very much the last kick you are a coding genius and will go down in the history books forever and ever and ever for those who don't understand what that is essentially the very beginning of the script we quit from from the script so thank you for the last kak the last kick has indeed had the last kak for those unfamiliar qeq is a mutation in the word Lowell lol so the last Lowell the last kak it's very fitting it won't be the last kak though I have a feeling blue penguin 9 is gonna take us home on this next line of code so lasso blue penguin 9 we're looking at you how can we fix this horrible situation we found ourselves in where we begin the script and we immediately quit the application as by this see this is me running the script and you can see immediately as I run it we quit it's over we do think blue penguin I'm not sure how to fix that to be honest walks rooks anybody in the chat want to give suggestions to blue penguin as to how we might go about fixing this problem folks that maybe are not trolls like last kak or potentially bad Bayesian we'll see what bad Bayesian has in mind but walks rooks got you and the choco kid good to see you choco kid as well as Abbey Shaw good to see you as well so boo penguin 9 anybody want to give blue penguin 9 some ideas blue bang blue penguin nines turn maybe something like if quit is equal to true I might get the syntax wrong though hey did you get the syntax wrong that makes the stream even more entertaining right replace work time with working time says success bucks try adding a def quit function before the quit and indent oh now Andre we are disallowing indentations of other lines at this time but what you said is still very true up until the indentation the indentation can be someone else's own idea own suggestion no it is a great suggestion however the the line but after it we need somebody else to say as much if user input is equal to quit directly above quit okay your wish is my command blue penguin 9 if user input is equal to quit blue penguin the blue penguin 9 and add semicolon as you wish semicolon added so there we go seems great right a tacit down cell Paulo wants to it wants to contribute I don't know Python they say but we'll try that's how you learn right I am absolutely in support of that and Skywalker pro oh the JP guy before that JP guy good to see you thank you for contributing so who we got next blue penguin 9 just to just contribute its to rule CS now it's a rule I know I know sir rule oh that right is instead of if I did because I'm terrible sir rule I have high hopes for you sir rule you are you have a history of solving problems on stream I know that we can expect great things and the current problem the current problem is we're creating a Pomodoro's so ideally and ultimate tension of this is up to the chat really but the Pomodoro is a tomato timer Pomodoro means tomato in Italian it turns out and thanks to the true canoes for kindly plugging that the goal of a Pomodoro is to have a time that you're supposed to focus on something for X minutes following those X minutes you have Y minutes of rest period so it's a meant to systematically allow you to work and rest right your day in a way that's easy to quantitatively keep track of Cerullo says modify line seven to if user input is equal to quit with a colon that is a brilliant way of fixing that line sir will see us I really got to hand it to you I mean that sincerely that is not sarcasm excellent way of fixing that so Cyril has kindly gotten us halfway there success bucks it is now your turn or be UX or books books success books line eight should be indented line eight should be indented well I guess this would have been line eight previously line line a line nine currently I'm hoping so line twenty two inside the if condition add a sleep timer for break time that could mean anything success books I need a line of code I need specific Python code I will not interpret your English if you give me a line of code I will place your name a mirror but I need a line of Python code not not English otherwise I mean I could write anything could be all kinds of things blue penguin 9 you have been consider yourself free added to the end again if anybody wants to write those three mr. Destructoid's get added to the chat get added to the queue of folks who want to add code from the chat to this script type those three mr. structor two emojis in that we have a long queue but it's not too late success bucks I'll add you at the end time dots sleep so this isn't here right right here or after the print just to be timed sleep break time is this where you wanted it or did you want it after after this line a mirror Kadir after the print they say okay got it trucha nieces drinka nieces laughing chuka nice this is why I have to be 100% sure that because those have two very different outcomes placing them in two different places je s coder has been added back to the list success bucks that was a mere Kadir maged Rifat who was a regular for some time and has recently come back mage let's get some code from you I'm very curious what you have for us today for this amazing Pomodoro Technique that's blossoming if assuming we can get past the first line of code at some point and thanks again to trucha nice for staying on top of pinging the folks that are in the queue line 17 should be working work time is equal to int of the input of length of working time oh I like that I like that amendment so this will be an amendment by mage drift fought and what we're going to do is we're going to change this to work time equal to the int of the input of the length of working time very nice change after all we do want to ensure that the value that we get from the user is an int value not a string value because numerically you can't compare I mean you can compare string looks in the string actually what a string evaluate to less than another string no I can't like actually off top my head I don't know so Python three if I were to say 1 is less than 2 is that true is 10 less than 2 ah see that's why you can't compare strings left-to-right or you can't compare strings as numbers in the sa

Original Description

Join CS50's Colton Ogden for more live-coding in Python, where the chat gets to write each line of code until we have a working script. Tune in on twitch.tv/cs50tv and be a part of the live chat. This is CS50 Live.
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from CS50 · CS50 · 0 of 60

← Previous Next →
1 Hello, World: Hadi Partovi
Hello, World: Hadi Partovi
CS50
2 Content Distribution and Archival in a Digital Age
Content Distribution and Archival in a Digital Age
CS50
3 CS50 2014 - Week 1
CS50 2014 - Week 1
CS50
4 CS50 2014 - Week 3
CS50 2014 - Week 3
CS50
5 CS50 2014 - Week 0, continued
CS50 2014 - Week 0, continued
CS50
6 CS50 2014 - Week 4
CS50 2014 - Week 4
CS50
7 Week 3, continued
Week 3, continued
CS50
8 Quiz 0 Review
Quiz 0 Review
CS50
9 CS50 2014 - Week 3, continued
CS50 2014 - Week 3, continued
CS50
10 CS50 2014 - Week 7
CS50 2014 - Week 7
CS50
11 CS50 2014 - Week 7, continued
CS50 2014 - Week 7, continued
CS50
12 Breaking Through The (Google) Glass Ceiling by Christopher Bartholomew
Breaking Through The (Google) Glass Ceiling by Christopher Bartholomew
CS50
13 Introduction to Amazon Web Services by Leo Zhadanovsky
Introduction to Amazon Web Services by Leo Zhadanovsky
CS50
14 CS50 2014 - Week 9
CS50 2014 - Week 9
CS50
15 How to Build Innovative Technologies by Abby Fichtner
How to Build Innovative Technologies by Abby Fichtner
CS50
16 Light Your World (with Hue Bulbs) by Dan Bradley
Light Your World (with Hue Bulbs) by Dan Bradley
CS50
17 Building Dynamic Web Apps with Laravel by Eric Ouyang
Building Dynamic Web Apps with Laravel by Eric Ouyang
CS50
18 CS50 2014 - CS50 Lecture by Steve Ballmer
CS50 2014 - CS50 Lecture by Steve Ballmer
CS50
19 CS50 2014 - Week 10
CS50 2014 - Week 10
CS50
20 This is CS50 with Steve Ballmer?
This is CS50 with Steve Ballmer?
CS50
21 Meteor: a better way to build apps by Roger Zurawicki
Meteor: a better way to build apps by Roger Zurawicki
CS50
22 Data Analysis in R by Dustin Tran
Data Analysis in R by Dustin Tran
CS50
23 Data Visualization and D3 by David Chouinard
Data Visualization and D3 by David Chouinard
CS50
24 CS50 2014 - Week 6
CS50 2014 - Week 6
CS50
25 Build Tomorrow's Library by Jeffrey Licht
Build Tomorrow's Library by Jeffrey Licht
CS50
26 CS50 2014 - Week 9, continued
CS50 2014 - Week 9, continued
CS50
27 Essential Scale-Out Computing by James Cuff
Essential Scale-Out Computing by James Cuff
CS50
28 iOS App Development with Swift by Dan Armendariz
iOS App Development with Swift by Dan Armendariz
CS50
29 Sam Clark Leads Yale Students on Tour to CS50 at Harvard
Sam Clark Leads Yale Students on Tour to CS50 at Harvard
CS50
30 3D Modeling and Manufacture by Ansel Duff
3D Modeling and Manufacture by Ansel Duff
CS50
31 CS50 2014 - Week 5, continued
CS50 2014 - Week 5, continued
CS50
32 hello, world
hello, world
CS50
33 CS50 2014 - Deep Thoughts - Hash Table
CS50 2014 - Deep Thoughts - Hash Table
CS50
34 CS50 2014 - Deep Thoughts - Binary Tree
CS50 2014 - Deep Thoughts - Binary Tree
CS50
35 CS50 2014 - Deep Thoughts - Scratch
CS50 2014 - Deep Thoughts - Scratch
CS50
36 CS50 2014 - Deep Thoughts - MySQL
CS50 2014 - Deep Thoughts - MySQL
CS50
37 LaunchCode Visits CS50
LaunchCode Visits CS50
CS50
38 CS50 Live, Episode 100
CS50 Live, Episode 100
CS50
39 CS50 Field Trip to Google
CS50 Field Trip to Google
CS50
40 This is CS50 AP
This is CS50 AP
CS50
41 Week 4: Monday - CS50 2011 - Harvard University
Week 4: Monday - CS50 2011 - Harvard University
CS50
42 Week 2: Wednesday - CS50 2011 - Harvard University
Week 2: Wednesday - CS50 2011 - Harvard University
CS50
43 Week 1: Wednesday - CS50 2011 - Harvard University
Week 1: Wednesday - CS50 2011 - Harvard University
CS50
44 Week 11: Monday - CS50 2011 - Harvard University
Week 11: Monday - CS50 2011 - Harvard University
CS50
45 Week 3: Wednesday - CS50 2011 - Harvard University
Week 3: Wednesday - CS50 2011 - Harvard University
CS50
46 Week 12: Monday - CS50 2011 - Harvard University
Week 12: Monday - CS50 2011 - Harvard University
CS50
47 Week 1: Friday - CS50 2011 - Harvard University
Week 1: Friday - CS50 2011 - Harvard University
CS50
48 Week 3: Monday - CS50 2011 - Harvard University
Week 3: Monday - CS50 2011 - Harvard University
CS50
49 Week 10: Wednesday - CS50 2011 - Harvard University
Week 10: Wednesday - CS50 2011 - Harvard University
CS50
50 Week 2: Monday - CS50 2011 - Harvard University
Week 2: Monday - CS50 2011 - Harvard University
CS50
51 Week 9: Monday - CS50 2011 - Harvard University
Week 9: Monday - CS50 2011 - Harvard University
CS50
52 Week 7: Monday - CS50 2011 - Harvard University
Week 7: Monday - CS50 2011 - Harvard University
CS50
53 Week 5: Monday - CS50 2011 - Harvard University
Week 5: Monday - CS50 2011 - Harvard University
CS50
54 Week 5: Wednesday - CS50 2011 - Harvard University
Week 5: Wednesday - CS50 2011 - Harvard University
CS50
55 Week 7: Wednesday - CS50 2011 - Harvard University
Week 7: Wednesday - CS50 2011 - Harvard University
CS50
56 Week 8: Monday - CS50 2011 - Harvard University
Week 8: Monday - CS50 2011 - Harvard University
CS50
57 Week 9: Wednesday - CS50 2011 - Harvard University
Week 9: Wednesday - CS50 2011 - Harvard University
CS50
58 Week 8: Wednesday - CS50 2011 - Harvard University
Week 8: Wednesday - CS50 2011 - Harvard University
CS50
59 Week 10: Monday - CS50 2011 - Harvard University
Week 10: Monday - CS50 2011 - Harvard University
CS50
60 Week 2: Wednesday - CS50 2010 - Harvard University
Week 2: Wednesday - CS50 2010 - Harvard University
CS50

Related Reads

📰
I Bought 128GB of Unified Memory to Run Local Coding Models. Here’s What Actually Worked.
Learn how to set up a local coding model on a MacBook Pro M5 with 128GB of unified memory for AI-assisted coding
Medium · LLM
📰
Companies Still Running Coding Interviews Will Be the Losers of the AI Era
Companies that still rely on traditional coding interviews will be left behind in the AI era, as AI-generated code becomes increasingly prevalent
Medium · Data Science
📰
Pre-allocate Like a Pro
Learn how to pre-allocate memory like a pro in C# 15 for efficient coding
Dev.to · Sukhpinder Singh
📰
The Real Divide in the AI Economy Isn't Human vs. Machine
Developers who combine AI with strong engineering fundamentals will thrive in the AI economy, rather than being replaced by machines
Hackernoon
Up next
Claude Code Local Google Ads: Automate Everything ($730K Earned)
Jono Catliff
Watch →