Code Break 11.0: Abstraction with Susan Wojcicki and China Anne McClain

(bouncy music) (countdown chiming) (logo chiming) – Hi, and welcome to Code Break My name is Hadi There are thousands of people who are joining us across Zoom, Facebook Live, and YouTube Live, and together we’re hoping to build the world’s largest live interactive classroom With so many students at home, my team at Code.org invites families everywhere to join us for a weekly dose of inspiration, community, and computer science I’d like to start by introducing our first special guest this week, YouTube CEO, Susan Wojcicki Susan, are you there with us? – Hi, can you hear me? – Yup, I can hear you okay The video is a little bit– – [Susan] Can you see me? – Yup, we can see you just fine And I’m here with my– – Sort of, not fine Hello? – Hello, this is my daughter Sofia, and she’s my sidekick on Code Break and she’s also a budding computer scientist – (laughs) Great, we need more computer scientists – We definitely do, especially young women like Sofia I wanted to start this week’s episode by addressing the events of the last week in the United States This has been something that’s on all of our minds At a time of a global pandemic, it really has pained me and all of us to see racism grip the United States and cause so much suffering, especially among black communities Code.org stands together with the black community, our employees, partners, teachers, and the students, in the fight against systemic inequity, racism, and injustice in the United States We thank all the teachers who strive for equity in our classrooms, who show empathy to a nation that needs healing, and who work daily to support the next generation to build a better future We all also know equity is broader than what happens in the classroom, and opportunity can’t be found when racism remains unaddressed in our world Susan, I also know YouTube put out a similar statement just a few days ago, and I don’t know if there’s anything you want to add to that– – Yeah – [Hadi] Go ahead

– Definitely, we were devastated to see those horrible acts of racial injustice, and we wanna to make sure that everyone in our society can feel safe And it was devastating for us to see, and so we made a lot of statements on the YouTube platform to make sure that we use our platform to stand up, stand up against racial injustice and speak up for what we think is right, which is bringing everyone together and enabling everyone to be safe And we’re making a donation to a group that does a lot of work in this area, and also using our platform to make sure that we can bring different voices together to process all the information and make sure that we can make sure that all the black voices that have so much to say and these others who really wanna chime in and talk about the challenges of injustice in our society, are able to voice their points of view and bring us all together for a better world so that everybody can feel safe And we’re continuing to do what we can And it’s a very tough situation, so I’m glad that, Hadi, that you brought this up at the very beginning, and that we can address it for everybody – So we would usually start our episodes with a computer science joke of the day but instead of doing that, what we wanna do instead is just stand in solidarity with all the victims of racism in the United States I want to ask everybody, including those at home who are on mute or not on the camera to join me in a moment of silence, to reflect on how we can all individually help make our world a better place And, Susan, if you don’t see everybody’s faces, if you click the little button that looks like this in the right hand side of your screen, that would help And if we could go to gallery view so everybody else at home sees all the faces on the screen, that would be great And we’ll start with a brief moment of silence All right, having spent that time, I wanna have us all first meet our live audience We have a few dozen students on camera Could we all unmute– – Hello? – [Students] Hi – Hello – [Students] Hi – Hello – [Students] Hi – We’re back to mute, and Susan, that’s the folks that you can see on camera, but most of the people on this call actually aren’t on camera To show you where our audience is calling from, as everybody was joining in, here’s a map of where people are calling from There’s a few people who fake their locations coming from Antarctica, but as you can tell, people are calling in, not only from all over the country, but all over the world, all sorts of different time zones, from Africa, from east Asia, from Hawaii For some of the folks, it’s at 7:00 a.m their time, for some folks it’s 1:00 a.m their time, which is pretty incredible As we go through these episodes, if folks have questions for Susan, you can submit them online You can go to Code.org/questions, and we’ll have a chance to ask your questions to Susan I know every single person who’s on this call is a user of YouTube, and you might have interesting questions Today, we’re gonna be learning about abstraction, which is one of the most important concepts of Computer Science, and we’re gonna have three parts Unplugged, we’re gonna learn about the functions, and then we’re gonna learn about libraries But first, and I want to start with a few questions for Susan, I’m gonna ask some questions and then some of our students have questions as well Susan, you were there at the very, very beginning of Google In fact, it started in your own garage Can you share a little bit about the experience of having a company as important and significant as Google, start in your garage? – Sure, well, it started because I knew the two founders of Google, Sergey Brin and Larry Page, when we were all just friends, no one had started any companies And I had just bought a house and houses are expensive, and I wanted to have someone help us pay the rent And so they had just started Google and they were having a hard time finding office space And so we just agreed, “Why don’t you just move in? “You can rent our garage.” And, actually, they entered through the garage, but they had a few rooms in the house too And they got up to about seven employees,

and it was pretty funny having a company in your house And at the time, it actually was pretty convenient because we got really good internet service and that was a big benefit for us But we had a few issues late at night because they would stay there all night working and, of course, we wanted to go to bed and sometimes they were making a lot of noise But overall, it was pretty fun to have them there in our house And when they got up to about seven people, we both agreed that it was a little too crowded It was not a big house, it’s a pretty small house, and we shared it with them But I think what it shows is that big ideas can come from young people, and Sergey and Larry at the time were still in school They were in their early 20s, and young people have a lot of really good ideas, and they saw this opportunity And I think the reason it’s relevant here is because we have a lot of young people and you probably are seeing opportunities that no one else has seen because our world is changing so much And that’s an opportunity for you to be able to seize that, and learning how to build these technologies will enable you to open up a lot of opportunities, just like it did for Sergey and Larry So it’s funny now because Google is such a big company, and at the time it seemed really normal to have them there working in our house – Sofia is hoping to start a company to sell soap Maybe she’ll be doing that in our garage as well – Probably not (Susan laughs) – So we have some students question, and there’s a bunch of these, so let’s try to get through them quickly So we have Kalkidan from Maryland If we could unmute her, and Kalkidan can you ask your question? – What was the first YouTube video that you watched? – That’s a good question – So, I think I could answer that in two ways So we, at Google, started a video service similar to YouTube, and at the time we had something called Google Video where we just enabled people to upload videos And the very, very first video I ever watched of just uploaded from people from the internet, was this video of these puppets that were purple and they were singing in a language I had no idea I think it was Swedish or Danish And I thought it was the weirdest thing I had ever seen And I wasn’t sure what to think, and I actually had my kids with me and they looked at it We were all really silent after it ended, and then they all started laughing and they wanted to see it again And it was a lot of fun And then there was another video once we built Google Video, that was really our first hit, which were these two students that were singing to the Backstreet Boys in their dorm room And they actually had their roommate in the background doing his homework the whole time And it became a huge hit, it got millions and millions of views And it’s funny, it still makes me laugh today And it was the first time I really realized that we could have hits with short video, with just a few minutes of videos generated by regular people living their lives, sharing with the world their experiences – That’s wonderful All right, so we have Prithvi, I’m not gonna say your last name, Vijaykrishnan from Bombay– – Yeah Yeah – Go ahead, what’s your question? – [Susan] Hello? – So what is your favorite type of YouTube video? – Well, I like a lot of types of YouTube videos And we’re blessed at YouTube that we have so many different types of videos We have, of course, highlight videos, we have parody videos, we have learning videos, we have a lot of people who are just sharing from their lives, user-generated videos, but I would say probably what I’m most proud about at YouTube is the fact that we have a lot of learning videos And people tell me how they’ve been able to change their lives by learning so much material on YouTube that otherwise they never would have had And I think about YouTube as a giant video library that has any information you wanna learn about anything in the world And that is a free resource for anyone to improve their life or to learn something new And that’s one of the areas of YouTube I’m really proud of We also have a ton of entertainment as you know, and music videos, and (cuts off) videos So all parts are in (cuts off) and it’s the combination of all these parts that make YouTube the special place that it is – And Kofi from Ghana has, I think, a related question

– Yeah, yeah, my question is that, what learning videos do you or your kids like to watch on YouTube? – Which what, did you say? – What learning videos do you or your kids like to watch on YouTube? – I couldn’t quite hear the question I heard something, “Which something do you and your–” – What learning videos do you, yourself, watch– – Oh, which learning videos do we like? Well, probably my favorite learning videos to watch on YouTube are when my kids ask me a question and I don’t know the answer And that actually happens a lot, where they get stuck, they need help with Math or Physics or some kind of science and I can’t explain it So I just say, “Hey, why don’t you go to YouTube “and look it up there? “I’m sure there are many videos that explain that.” And, usually, almost always, there are many choices from that So that’s one area that’s important I also say there’s a lot of nice exercise videos on YouTube So whether you’re interested in yoga or fitness, especially when people are on quarantine, there are a lot of great programs that we can do to just do exercise in our house, and those are really important, especially right now But thank you for your question And I’m glad to see such an international audience here – Yeah, I bet you didn’t expect you’d be speaking to people from Africa and India, at the late time of their night right now – Yeah, they’re from every continent here So it’s great to see that – So from Virginia, Layla has a question, in the United States – Okay – What are you excited about in terms of future directions of YouTube? – Many things with YouTube that I’m excited about for the future So I am excited about, certainly enabling the next generation of creators So we probably have lots of people here on the call that at some point will be a creator on YouTube, and so we’re excited about enabling all of you And we think there’s a lot of ways that video can continue to be developed, ways that we can make it more interactive for people I also think there are other areas that we’re really just getting started with like VR, where it can be really compelling but we just don’t have that many people right now who have access to VR headsets or VR content, but I think that can be really compelling in the future And just continuing to grow all of the YouTubers out there who have so much wonderful content to share with the world, and making sure people can find it and grow it So that’s just some of the areas that we’re invested in going forward – I have two questions myself, Susan The last week’s episode, we talked about artificial intelligence and machine learning and how computers can recognize patterns How does YouTube views AI and machine learning? – Yeah, so YouTube couldn’t function without AI and machine learning because we use it in every part of YouTube So first of all, we use it in the recommendations that we make So when you come to YouTube and we need to decide which video should we show you, we use machine learning to try to figure that out in our recommendations So YouTube has 500 hours of video uploaded every minute And so when you come to YouTube, we need to look over literally millions and millions of hours, and figure out what’s the right video to show you And so we use machine learning for that We also use machine learning to keep people safe on our platform So we use it as a way of finding content that we think might not meet our policy requirement So something that would be a violation, like something that would promote violence So we use machine learning to find videos that we think would be a violation I think about it, in terms of our machine learning castle, a really big net, and then we have people who review those videos to see, is it true that they really are violating our policies, but also all of that is with machine learning And, of course, our ads too How do we decide which ad to serve on a video? That’s also based on machine learning So pretty much everything we do at YouTube is based on machine learning – That’s not you personally recommending the videos? – No, no We have two billion users and 500 hours uploaded every minute So in order to make that match between the billions of users and the millions and millions of videos, I mean, probably billions of videos, we need to use machine learning And so, YouTube really only can exist

because of machine learning – Every minute, 500 hours of new videos are added to YouTube by people on YouTube, it’s crazy – Yeah, so we need to figure it out Is this a video everyone wants to watch or is this a video that is a problem for our policies? There’s no way we can do that with people, we can only do that with machines – Yeah, one of the most interesting things that we talked about this last week is about how hard it is to have machines enforce policies And you have humans deciding what the policies are, but you can’t have the humans themselves watching every video and how you need to basically build the technology to enforce policies And when those policies are deciding what you can show to people or not, it’s a complicated issue, and I know you’re under– – It is very complicated And we also make sure that machines learn the right thing So that’s the other thing that happens sometimes So we give the machines a set of videos that are an example of the videos that are violating our policy, but we need to make sure that they learn the right lesson And if they don’t, then we retrain them so they start learning and finding the right videos – So I wanna take a little break from questions and introduce our Computer Science topic of today, which is abstraction And we’re gonna do a quick lesson with everybody, including Susan So abstraction is a concept that we use all the time, not just in Computer Science And what it basically means is taking something complicated and making it really simple So that when you have a bunch of complicated details that you don’t wanna care about, you can really simplify them down For example, if I were to give Susan driving directions to get from my house to Sofia’s school, I wouldn’t start by saying, “Open the garage door, “open the car door, get in the car, “take the key out of pockets, put the key in the ignition.” I would just say, “Get out of the street “and take a right turn.” And you wouldn’t need me to say, “Put your hand “on the steering wheel,” and all those little steps because we know how to do those things We abstract them away and just say high level words like, “Go on the freeway North and take exit 15.” I wanna show how we can, all of us together very quickly, learn similarly to basically go from really detailed steps to release simple commands using abstraction So please follow along with me, and, Susan again, if you aren’t in the gallery view to see everybody’s faces, go into this view and we’re gonna make sure everybody at home sees that So I’m gonna give you commands to all follow along So everybody raise your hand up like me and Sofia All right, now make a fist And if you’re at home, even if you’re not on camera, do the same thing Right, now stick out your thumb Right, let’s call this the number one This isn’t really how we show the number one anywhere, but let’s just pretend that’s how we’re doing it All right, now lower your hand That was the number one Now do it again, pick up your hand, make a fist, stick out your pinky finger Let’s call this the number two, all right? Now put your hand back down All right, and now we’re gonna learn a third number Raise up your hand, everybody Make a fist, stick out your thumb and your pinky finger, and if you want, you can wiggle it like Sofia just did Let’s call this the number three So we’ve just learned a very simple language with three numbers, and using abstraction, instead of giving you all those instructions, I can repeat them again Susan, did you get that complex language we just– – I think so I think so, I think I can handle that – All right, so now I’m gonna use a more high-level command I’m just gonna say, using that new language, count down from three to one as I’m gonna count out loud So three and then two, and then one And what we did, basically, I didn’t need to say, “Pick up your hand, “make a fist, do this and that.” Once you learn what a three looks like and what a two looks like and what a one looks like, you can abstract away those details Abstraction is so critical to Computer Science and generally to communication It’s what enables us to build really complicated computer programs without having to look through millions and millions and even billions of lines of code We’re gonna learn more about how to do that on a computer, but I wanna finish some of our questions with Susan And we have some questions, actually, from the audience So I’m gonna introduce Leo Ortiz to ask these questions for us Akira, who usually produces Code Break and asks the audience questions isn’t here with us today So Leo, are you there with us? Can you join us? – I heard a yes And hi, Susan? We got dozens and dozens of questions, we’re gonna read a couple of them Lily Grayson from Washington State,

she asks, “What challenges have you encountered “getting to this stage in your career, “and do you have a message for young girls, in particular, “based on your experiences?” – Yeah Well, I’ve definitely experienced lots of challenges I don’t think anyone ever has setbacks Everybody has setbacks along the way And I would say the message that I have for young girls is that Computer Science is a really valuable and important field And I really care about that a lot because they see that we just don’t have enough young girls and we don’t have enough women in Computer Science And that’s really a problem because all of the future world that we’re building is gonna need Computer Science And so we wanna make sure that that’s a world that’s represented by everybody, regardless of their backgrounds And I’ll tell you my story I never thought I’d be interested in Computer Science I never, ever like considered that when I was younger, and that was probably for many reasons like we didn’t really have as many options (cuts off) but I love doing creative things I love making art projects and building things And when I discovered, by accident, Computer Science, I realized that I could build things that everyone in the world could see and could use, and that I could just take a few classes and that would enable me to do a huge amount of work in the future And I was actually a senior in college when I discovered that And I thought I was too old and it was too late for me to change careers, but I decided I would just take the classes anyway, and those classes changed my life And I’ve seen it with my own kids, that it’s really important to have it and to not give up, and that everyone is capable of learning it Everyone, no matter who you are, no matter what your background is, you are capable of learning it, and you will need it for the future just like you need Math, just like you need Reading It doesn’t mean you’re gonna become a mathematician because you take Math It doesn’t mean you’re gonna mean be an English professor because you learn how to read, but you do need those basic skills to do everything else in the world And the same thing is for Computer Science in the world, going forward You will need it, and it will open up a lot of doors So I really encourage you all to take it and to stick with it, and I wanna, again, emphasize, this is something that everybody can learn Everyone, no matter who your background is, where you are, you can learn it – In a related question, Don Wu and Rico Sri from Dubai, they ask, “Do you have any advice for young people “interested in the field of technology today?” – So my advice for people interested in the field of technology today, is to, well, first of all, to have a understanding of Computer Science That will always open up doors, if you understand how technology is made, and, again, you don’t need to have that much because it’s always changing You just need to have a willingness to wanna learn and to keep learning as technology changes And I think the other thing that I would encourage people to do is just be curious and explore And there are so many ways that technology is changing our world, and so it’s possible that you’ll discover some area that hasn’t yet been explored by people and that you have some ideas that are new And I really think that that could happen because there’s just so many opportunities that are still out there And so I would encourage you to explore and ask lots of questions and have fun, get together with your friends, think about projects of things that would be useful to you That’s one way to think about If you ever are doing something, you’re like, “Wait, why does it not work this way? “It really should work this other way “It would be so much better.” Get together with your friends and think about how you could change that because you probably could, and this is the time to do it And don’t give up If one idea doesn’t work out, just find another idea There are a million, you’ll find another good idea And just keep at it, and don’t let anyone tell you that you are too young, that you couldn’t do it I’m sure you can do it Just be persistent and keep working on it – Tinkering, creativity, and persistence

are all so important for people studying Computer Science Thank you so much for your advice, Susan, and for joining us today And we’re gonna switch to, again, to gallery view, so all the students on camera, if we could unmute everybody to wave goodbye to Susan as we thank her – [Students] Bye – Bye, everybody (audience talking drowns out Susan) – I’d like to welcome our next special guest, actress and singer, China Anne McClain Hi, China? – Hello, how are you? Can you hear me? – I can hear you and I saw you earlier joining us for counting one, two, three – Yeah, you saw me Three, two, one. (laughs) – Where are you calling us from? – I’m calling from Georgia, I am at my home right now – Georgia, wow, and do you have any words you wanna share with the students who are studying at home? And as you see, the students here are from every continent and all over the world – Yeah, yeah, I can see I’m just really proud of you guys I think that it’s really incredible that you’re all this interested in something as extensive and awesome as Computer Science I’m really proud And seeing all of your little faces on this chat, it really does give me a lot of hope for the future So you guys, stick with it Seriously, stick with it Like Susan said, anyone can learn it and you guys can do it – Absolutely One of the most important things as you see from the folks here is the diversity of the faces The field of tech and Computer Science is predominantly white, and it’s predominantly male And what’s fantastic is watching the next generation of students who are basically representing, obviously, like my daughter Sofia, and there’s so many students from all over the world The young folks here are changing the face of Computer Science, and together they’re gonna help us build a better future – Yes, they are And go ahead, Sofia I see you representing for the women in the field, the young women Go ahead, girl. (laughs) Oh, she’s so cute – Thank you But we wanna, before we go into the next part of our lesson, we wanna take a break for a quick trivia question It’s trivia time (playful sound effects) Sofia makes sound effects So we have a question, what was the very first smartphone, and if you don’t see the poll on screen those of you who are on YouTube Live watching, was the first smartphone the iPhone 1, the Palm Treo, the Simon Personal Communicator, the BlackBerry 5810, or the Pocket PC with Windows Mobile from Microsoft? There’s lots of choices China, what was your first smartphone? – Oh, my gosh Is it sad that I don’t even remember? I don’t even think it was able to take photos. (laughs) – I have multiple of my first smartphones here for just those trivia questions Sofia is really embarrassed (mumbles) So this is the iPhone 1 right here – Yes – This is a BlackBerry, the first BlackBerry phone that came out, and this here is the Palm Phone They actually still work I actually used the iPhone (laughs) a few days ago just to test that it works, but I’m gonna share the screen Actually, look, can we show what the students guessed were the results? – Mm-hmm, they guess the BlackBerry 5810 – BlackBerry came, yeah So now I wanna actually do a quick screen share to show the answers So where is my screen share? Thanks, Sofia So what you can see is the iPhone 1 is what a lot of people think, but that actually, of the list, was the most recent of the smartphones, not the Palm Treo, not the Microsoft Pocket PC, not the Blackberry, but the Simon Personal– – Yeah – Look at this bad boy made in 1992, so 28 years ago This was the first smartphone So I always love learning something new with Computer Science trivia – (laughs) That is dope I wanna get me one of those. (laughs) – Carry that around? I don’t know if you can tweet with it, though I didn’t see if it had a full on keyboard for using Twitter – It didn’t look like it did (laughs) Look at her holding that phone up That means you took really good care of it if they still work, good for you – Yeah, it’s pretty amazing that they still work We’re gonna skip into learning our next part of today’s lesson about abstraction We’re gonna learn about using functions And a function is a type of abstraction Remember earlier when we were holding up our numbers, one, two, and three, and I didn’t need to repeat all the commands, I just said, “Show the number one,”

and you knew how to do it? Functions are basically the exact same thing in code When you write a bunch of code, if you wanna do the same thing over and over again, you don’t need to repeat all the code you wrote earlier, you use a function to do it And I’m gonna demo this in a game that I started building, and then Sofia is gonna finish that game And as Susan was talking about projects and tinkering and creativity, that’s exactly what we’re gonna do here We’re gonna tinker with a project that I already started So what we have here is a game on Code.org Just to first of all show what’s happening on the screen, on the left side here is where this game is gonna be playing On the right side here is all the code, and some of this is already started, and here are the commands for all the other things we could add to the game So I’m gonna start by just looking at the code You can see when we run the code here, it does this thing called game setup What does game setup mean? This is a function And if I click, you can see all the code that is involved in game set up, but you don’t need to know those details, right? It just says game set up And then up here it says when I hit the Right key, move this little rabbit east, and when I hit the Left key, move it west So Sofia, we’re gonna hit Run, and then you’re gonna use your mouse to click on these keys to control that little rabbit, to move him right and left Go So you can click Right and Left and when you hit the Down button, the rabbit drops little carrots to make stew Your rabbit is making carrot stew (scorestreak chimes) So each time you do it, it also shows how much stew you’ve made Right, so that’s a pretty simple game You’re making carrot stew And if you look here, and here’s the code that says, “When the Down button is pressed, “make a new carrot and have the carrot move south.” And by the way, China, if you haven’t seen code that looks like this, you can Usually, when you see code, it looks like this and it’s a whole bunch of texts, but we’re using blocks, which is basically the same concept, it’s just a little bit easier with a younger age So here is the code for what happens When one of those carrots hits one of these empty pots, it plays the sound, the carrot disappears, and we change the pot into stew And we then print something But I wanna write the code and add the code for what happens when the carrot hits this hungry rabbit See this little brown rabbit that was going back and forth? So what should we do when the carrot hits the hungry rabbit? What do you think, China? – I don’t know, you tell me – How about we have the hungry rabbit eat the carrot so it can’t go into the stew? Does that work? – Aww, I guess so I would have liked him to drink the stew, but sure (Hadi laughs) (China laughs) – It’s standing in the way and since it’s a computer game, the hungry rabbit’s our bad guy So Sofia, we wanna add some code When the carrot hits the hungry rabbit, we wanna make the carrot disappear So go under Sprites and remove the carrot So don’t remove the good guy, just take that out, you wanna remove the carrot And we learned earlier that the way to do this is by taking this sprite You wanna remove this sprite, which is the subject of this one block So in the event that that happens, we remove the carrot We should also play a sound, so go into into the World category and pick up Play Sound Oh, and when we get to choose what sound we wanna do So we click Choose and click here where it says Collect, and China, I want your help choosing the sound when hungry rabbit eats the carrot So let’s try the lead options Clicky crunch (crunch clicks) (China laughs) Bar recharge (Bar recharges) And then health pack (health pack chimes) – (mumbles) – I like clicky crunch – Clicky crunch? (clicking crunch) – Yeah. (laughs) – All right, let’s choose that as the sound for when our hungry rabbit eats the carrot Right, so now the carrot disappears, but there’s some other stuff we can do as well We want to, basically, lose the lives If you look at the top of the screen, it says Lives: 3 We wanna lose lives each time the hungry rabbit catches our carrot So to reduce lives, lives is a variable, which we learned about a few weeks ago Go under the Variables category, and see where it says Change i by one? Oh, no, not that one Change i by one, that’ll change our variable, And we wanna change the entry for lives So instead of changing i, change lives No, that’s two – That’s two (laughs) Lives And you don’t wanna increase the number of lives, you wanna decrease them So instead of changing them by one, we wanna change them by negative one All right, and now you can also print the number of lives you have left There is a print block here, and if you hit Command C, Command V, you can make a copy of that block, that’s gonna print out how many lives we have left That’s the code that prints how many stew you have, but now we can have how many lives we have left

– It still says stew Why do I keep clicking the wrong line? – It’s okay You can change the lives – (mumbles) All right, so now let’s run it and see how it works All right, so now Sofia has– – (mumbles) (scorestreak chimes) (China laughs) – So Sofia negative 10 lives left She made two stews and negative 10 lives Is there something we’ve forgotten? What does negative 10 lives mean? (Sofia laughs) How many negative lives do you have, China? – Negative lives? A lot, more than 10 – What usually happens in a computer game when you start losing too many lives and when you go past zero, what happens usually? – You lose – You lose So what we didn’t do is we didn’t check if we ran out of lives And if you look at this code up here, it has this function called Check If Game Is Over And we can actually drag this block, check if game is over, and add it over here And Sofia, can you click the edit button? Because that function doesn’t do everything we want it to do Right now, it says, “If the stew is five, you win.” So you win when you get five stews But we wanna say you would lose if you get down to zero lives So click this entire if thing and copy it and paste it with Command C, Command V – So – All right, and now instead of checking if the stew equals five, check if the lives equals lives equals– – Zero – Lives equals zero, and right now it says, “You win! Play again.” China, can you tell us something else to put over there? – It should, unfortunately, say, “You Lose, Try Again.” – You Lose Try Again Include Sorry, so we can be nice to it – Yeah, sorry, (laughs) right I would put a smiley face too, but that’s okay. (laughs) – (laughs) So let’s also now change the sound because the winning sound is not so great What sound should we put? So let’s search for losing sounds So we can get bunch of losing sounds, and I was going over these earlier So here’s a bunch of fun losing sounds There’s the female voiceover, – [Female Voiceover] You lose – (laughs) which is a very aggressive, “You lose.” There is the 8bit Game Over sound, (8bit game over sound) and then there’s the crackle loss sound (crackle loss sound) – Aww – And let’s have the students do a poll to choose between those The female You Lose sound, the 8bit game over sound, and the crackle loss sound Can we put a poll up on screen to choose? All right, so now all the students (China laughs) All right, so there’s Oh, my gosh There is an obvious winner and it’s not what I expected China, do you see the votes that are coming in? – I do, oh, oh – All right, almost everybody’s voted, this is not what I thought you people would choose (China laughs) And now, let’s share the vote results (bell chimes) It sounds like people want the female voiceover sound – You lose – You lose (China laughs) – Now, was that you saying that, China? – That was me, was it good? – Yeah, that’s pretty good Choose that sound, Sofia – [Female Voiceover] You lose – That’s right Now, let me close this All right, so, and that’s basically it for our little gameOver function Now that we checked this game is over, we’ve written that code inside here, we don’t need to deal with it ever again to learn about the details, and I think our game is finished now So hit Run – We’re trying to lose here to test our new code (rabbit purrs) (scorestreak sound) – Oh, no – [Female Voiceover] You lose – Oh – But it said sorry It said sorry, that’s nice Right, do you want another game, Sofia? Because you haven’t won yet – Now, I’ll run Run – All right, let’s see if she can win this game (scorestreak chimes) Then stew – And that’s a little risky – That was risky – That’s what I need to do I am gonna– – You have only one life left – [Female Voiceover] You lose (laughing) All right, so one thing you can do, now that we’ve written this game is we can share it out So I can say Share Your Projects, and here is a QR code And, in fact, every student, if you have a phone and are watching this, and China, you can do this if you want, if you have your phone and use the camera, you can scan the QR code, this little code here, and you’ll get a little notification on your phone, and then the code that Sofia and you and I wrote, you can click on that and you have our little game up there Look at that, please Is that pretty cool? – Oh, my gosh

Oh, wow – So the sounds you chose and the app we just made is now on your phone, which is cool (laughs) Yeah, isn’t that awesome? – That is awesome. (laughs) – (laughs) That’s part of the joy of creativity with Computer Science and coding And for anybody who didn’t have a phone because you had only one device, we’re gonna be emailing you that game at the end of this episode, so you can actually change it and make improvements yourself And what’s exciting about Computer Science, basically, is the creativity of basically making something your own and changing it, and we have a bunch of modifications for things we want to let you add to your game Now, before we get to the next segment of the episode, we wanna do a lightning round of questions with China So you’re our fifth special guest to play our lightning round game We’re gonna put 60 seconds on the clock, and Sophia has an app that we made that’s gonna keep score Your goal is to get through as many questions as possible – Oh, goodness – Yeah, and we want quality and quantity, but we’re measuring based on quantity And our current high score was 14 questions answered in 60 seconds by Macklemore It’s unlikely doing that, but can try So Sofia, are you ready? – Yeah – China, are you ready? – Yes, I am – [Hadi] Okay, go – Go – [Sofia] Favorite drink? – Sprite – [Sofia] You favorite smell? – Outdoors – [Sofia] An activity you can get easily sucked into four hours? – Scrolling through TikTok – [Sofia] Something you can eat everyday – What do I eat every day? What was that? – [Sofia] Something you can eat everyday – Pizza, unfortunately – [Sofia] Best book you’ve ever read – The Bible – [Sofia] Something you can’t ever eat no matter how many people love it – I don’t like onions, I’m sorry – [Sofia] As a kid, what did you want to be when you grew up? – A singer – [Sofia] What are your feelings about pineapple on pizza? – I love it, I don’t get the hate – [Sofia] The last person you hugged, not living with you – Probably my friend, Lauren Norris, or a fan that I met Go ahead – [Sofia] Something you know all the words to, oh, no, okay, that’s– – [Hadi] Oh, we’re out of time What was your score? – [Sofia] It was was nine – [Hadi] You’re score was nine Gosh, I don’t even know how Macklemore got to 14 – I think it was– – I know, he was giving one word answers. (laughs) – All right, well, (clapping sound effects) China, do you have any last messages for our students at home? I know you’re out of time Do you have any closing comments you wanna share with the students? Any words of inspiration? – I would just say that in this field or whatever field you are in, honestly, I’ve taken this into acting and in everything that I do, don’t give up Don’t be discouraged, don’t let anybody tell you that you can not do something Anytime I hear that, it makes my mind moves even harder and I want it even more So don’t give up, and yeah That’s all I would say That’s all I would say to you, guys And I’m very, very proud of you once again. (laughs) – Thank you so much And I hope you learned a little bit of something with us today as well – [China] I definitely did – Let’s switch to gallery view so we can see all the students on screen, and wave goodbye to China – Bye, guys, love you Three, two, one. (laughs) – All right, bye, bye And now we’re also gonna say goodbye to Sofia She’s gonna be leaving as well, and we’re gonna be joined by my son, Darius Darius, I’m gonna shift over and– – Hi – Hi, Darius Darius is 13 and he’s a slightly more advanced computer programmer And for our last segment today, we wanna talk about libraries This is a portion about abstraction We learned about how functions work, and libraries is something really exciting that we actually just added to Code.org this week, and it’s a really important concept and capability So a library in Computer Science is a lot like a library in the real world In the real world, anytime you want to get a book that you don’t have, if somebody else wrote that book, you can go to the library and borrow it and then read it In computer science, if there is code that somebody else wrote and you want to reuse that person’s code, you can basically use a library that lets you use the functions that somebody else created, without having to learn how they work and all the little details, you can basically use their code as well And to introduce this, I’m gonna invite Hannah on screen Hannah is one of Code.org’s Computer Science Curriculum Creators She used to be a teacher herself, and then she used to help prepare other Computer Science teachers, and now she is one of the authors of our CS Principles Course, which is the most popular high school Computer Science course in the United States

So Hannah, can you join us and show us how libraries work? – Hi, Hadi, I am happy to show our new tool I’m super excited about this So I’m going to share my screen now And what you’ll see is a program And in this program, I have lots and lots and lots and lots of lines of code But what’s really cool about this code is all of this code can be contained within functions And what’s great about a library, as Hadi was saying, is I can take these functions and I can share them with somebody else So, for example, I’ve got this first big green block here, and this is my butterfly function And inside of my butterfly function, I’ve got directions for how to draw a butterfly, and I’ve also got, right here, another function that I’m calling To Draw a Part of the Wings And I’m actually gonna show you how this works So I’m gonna call my butterfly function And if you notice up here, it takes two different parameters So two pieces of information I have to give it So I’m gonna say a size of 10, and let’s say a pink butterfly Oh, I did not run my program, gotta do that first Let’s try that again, butterfly(10, “pink”) Okay, so there we go So I’ve got a pink butterfly on the screen, and you’ll see right here, it draws wings and this is this bottom set, and then I call another function drawings again, to draw these top wings at a different size So you can see that I can reuse functions several times, just like we did in the Sprite Lab project, and I can do that all within this butterfly function Now, I have functions here for grass, I have functions for flowers and for ants, and for clovers, all sorts of things to draw interesting things on my screen But what’s really fun about libraries is that it’s not about what I draw my screen, it’s about what somebody else can make with my functions So I’m gonna show you now how this works So I’m gonna click on Share, and then I’m going to click Share As Library And once I click that, now I have the option to choose the functions I want to send to anybody in the world But first I need to give it a description, so they know what’s in this library So I’m gonna say, “A collection of drawings to– – So can you send that library to us to make some code using it? – Absolutely – I mean, we can use all the functions she just created – [Hannah] All right – That’s great – So I’m gonna choose some functions to send over to Hadi and Darius I’m gonna send the butterfly, the grass, the flower, the ant, clover, ladybug So those are the functions that I’m gonna send And I’m going to click Publish And once I do that, I am going to get a special code right here And this code, I can copy and I can send it over to anybody, and I’m gonna send it right now over to Hadi and Darius who are going to make something with my library – All right, Darius, are you ready to check this out? – Yup – So we’ve already started making an app that’s gonna draw, basically, an outdoor scene, and we were ready to get this library of code from you So here is this app that I started And, basically, the idea here, this is in design mode, the idea is to basically have an app where if you run it, you can choose how many clovers you want or how many flowers you want or how many butterflies, and you click this little pencil and it draws them for you But right now it doesn’t work If I click it, it basically does nothing because we don’t have the code to do that We needed to add the code for drawing the clovers and flowers and butterflies, and we can only do that using the new library you made for us So to add that, you need to go to this little gear in the upper right of the toolbox– – That one? – Yeah, and choose Manage Libraries All right, and see where it says Import Library From ID, click there, and I’ll hit Command V to enter the code that Hannah gave us And now I’m gonna hit Add, that’s gonna add the library of all the functions that Hannah has made She wrote those functions and they were on her computer, but now we can actually access them So we’re here in an App Lab in code mode, and you can see there’s all these different categories of all the commands inside App Lab, but if I click under Functions, look at that There’s six new functions These blocks didn’t exist before We just added these blocks to App Lab They are the code that Hannah wrote, and now we can use them in our project to do anything we want with them – Whoa – Isn’t that pretty cool? – What about the functions inside the functions– – Those still work – Oh, that’s cool – Which means also that anything you create as code, you can share as the library, somebody can use it in their code, or they can use that to make an even bigger library,

and that’s how so much of Computer Science works Not everybody creates everything from nothing, they build on the work of other people So now, if you look at this code that we have right now, I’ve already started up here Basically, this is what happens when the Draw button gets clicked And, by the way, I’m in text mode, not in block mode, because we’re getting near the end of Code Break and we wanted to just teach kids more advanced coding So when the Draw button is clicked, here it uses the OutdoorScene.grass command The grass command came from the library that Hannah wrote And then to draw the clovers, it uses a for loop, which is a repeat counting from zero up to the number of input1 GetNummber of input1 tells us the value of this little slider here If you look here, it says id:input1, that tells us that that’s input one And then what it does is lifts up the pen, goes to a random location, and points in a random direction, and calls the OutdoorScene.clover So now what we wanna do, Darius, is to have you draw the flowers and the butterflies, and you can copy the code up here So what I would suggest is basically copying and pasting the code to draw the clovers, and to change them to draw the flowers So instead of counting from zero to input1, how do you know how many flowers we have? – If input2, and I’m assuming this is input3, yeah – All right, so change that to input2, and then you have that code to move you to a random direction and so on And now instead of drawing a clover, take out the command that draws a clover, and instead add the command for flower – There – There you go And now you can see for your flower, you need to add a size and a color and a number of petals So what size do you want it to be for the flower? – Probably a random number because not all flowers are of the same size – Okay, so how big do you wanna increase them? Two– – Two, two, eight – And now making them even bigger, maybe – No – Okay, and then what color should we make for our flower? Why don’t we have the audience choose the color? Can we just put out a poll on the screen with some different color options? So orange, pink, gold flowers, aqua flowers, I wonder what people are gonna choose I would have thought that people would choose gold as their favorite color, but there aren’t that many gold flowers in the real world either (Darius chuckles) All right, can we share the poll results? All right, the majority want aqua flowers, right? So for our color there, we need to type aqua And Darius, can you explain why you put the little quotes for the aqua? – Because if you don’t have the quotes, the computer sees aqua as a variable, which will mess everything up – Yeah, it would think that it’s a variable You wanna pass the value aqua, not the name of a variable called aqua – Yeah And then petals is how many petals do you want? – Four – Why don’t you just put in five, have all the flowers? – Random number – Okay, you can have different shapes and sizes – I want some flowers to have loss of petals, the integer is four to 12 – 12-petaled flowers All right, so now let’s run the code for this and see how it works – Run – So add some clovers and flowers – The butterfly is doing nothing right now, so – So it draws the grass, it draws the clovers, and look at it, we drew a whole bunch of flowers So let’s also, real quickly, add the butterflies But one thing I wanna point out is you know this code here that we copied each time, moving the pen and so on, if we copy this every single time, it’s basically repeating all of these same details over and over and over Can you think of what we could do to not avoid repeating the same details and code using abstraction? – We could store it in a function like– – Yeah, we could put that code in a function So let’s make a new function for just that code It’s called myFunction, and then take that code that, what do you wanna call it, son? – I’d like to call it moveRandom – So it moves you to a random location? – Yeah – All right, so copy that code that moves you to a random location, and you’re gonna hit Command C, Command V All right, so this is our function, it moves us to a random location So everywhere else where we did that, we don’t need to do all those three lines of code Those same three lines of code everywhere else that we see them, we can instead just call your one new function, moveRandom So this is just like we were teaching you how the number one looks like this, or how the number two looks like this If you maybe later wanna say, “Show the number three,” you don’t say, “Move up your hand “and stick out your thumb and stick out your pinky,”

you just say, “Show the number three.” That’s basically what we’re doing here Instead of having to repeatedly say, “Pen up, move to a random this, move to a random that.” So one thing I also wanna show is you can even hide this function All these details, you can click here to hide it and just not even worry about it That code basically does what it does, and we’re gonna use it from now on So now let’s add, finally, the code for writing the butterflies by copying the code for writing flowers, and we have just about maybe 20 seconds left to do this So instead of getting the number from input2, we’ll get it from input3 – MoveRandom, and you have to put butterflies – Yeah, so bring out the code for butterflies, and every butterfly has a size Do you wanna pick a random size again? – Four to ten There might be a bit– – You’re right, and what color should the butterflies be? Do you wanna make them red or something else? – We should probably use this thing I saw earlier – Oh, there’s a drop-down there, input4 Okay, so to do that, go under UI Controls – Okay And see where it says, getText, pull that out, and put that That will get the value Instead of “id”, put “input4” there That’ll get the value of that drop-down So now you can run this app – Oops There – And you can choose how many clovers you want and how many flowers you want, and how many butterflies you want– – No, I don’t want that many – And then choose a color for the butterflies How about black or yellow? – Definitely not green How about red? – All right So now we have the grass and then the clovers and then the flowers, and then the butterflies in our scene – What about the ants and ladybugs– – The ants and the ladybugs, we have a code for making those, but we wanna let everybody else make those – So we’re leaving them out? – Yeah, we can add them later And also, by the way, there’s these buttons here to hide these controls or to show them, I didn’t walk through that as well, the code for those is over here, and they were hidden so you don’t need to bother seeing those details Those are also hidden in functions But this, basically, is a very simple app that lets you make your own scene Instead of sharing this out to you right now via the phone, we wanna send it to you to have you create your own addictions to this using the library that Hannah shared So you can add the ants and even the ladybugs The ladybugs look really cool And that’s basically it in terms of the app you wanna make So what we want to do is if you haven’t already signed up for our emails, go to code.org/break, and we’re gonna send you this week’s challenge assignment, and we’ll do a bunch of things First, you’re gonna practice learning how to use functions in a really fun Minecraft tutorial, and then as the challenge, you can either use Sprite Lab, using functions, to make your own game just like Sofia was doing, or you can use App Lab and take the library that Hannah made with the ants and butterflies and so on to make your own outdoor scene, or even to create your own library to share that with us And as always, if you email us what you create, we’d like to invite you onto the next episode And I wanna say last week is our very last episode of Code Break – Next week, you mean? – Sorry, next week. (chuckles) Next week is our very last episode because school is ending, and for most of you, summer is starting And we have a really special jam-packed episode with three special guests We’re gonna be joined by the inventor of Google Maps, the singer and songwriter, Aloe Blacc, and also, lastly, a product manager for Microsoft Teams who also used to work on the Xbox And so this should be a really fun episode Before we close, I wanna recognize, again, that we’re at a really historic time of unrest here, not just with the pandemic but with the marches and protests that are happening here in the United States And I know all of you students are at home or going through a difficult time whether you’re in the United States or elsewhere Our thoughts are with you, and please stay safe, and please stay learning It’s the best way you can change your future and help us make the world a better place If you’re studying alone, take a Code Break, and we’ll see you next week Bye, everybody (bouncy music)