Placeholder Image

字幕列表 影片播放

  • I'm still feeling like someone's with me.

  • I know Tom is on because I know you're out there somewhere.

  • Patients waiting on wear feeling like your grip might slip chasing speed and I'll be right there.

  • You're be lead me straight to the O I know.

  • Wait.

  • All right.

  • Hello, world.

  • This is CS 50 Live.

  • My name is Colton Ogden.

  • In case anybody's brand new to the Stream saves 50 is Harvard's intro to Computer Science.

  • Top by David Malin This is our stream where we do all kinds of fun stuff.

  • We build things from scratch.

  • We talk about things like Callie Lennox, which Nick Wong from Yesterday Stream happened.

  • Help us out with on a bunch of other things.

  • Talk about libraries, Talk about Webb, talk about games, all kinds of stuff.

  • But today is actually very experimental.

  • Today we're gonna do something completely different.

  • We're gonna kind of evolved from last week's text adventure game that we did, which was basically the gist of that was the chat wrote all of the text adventure lines in the text adventure, including branching paths and whatnot and sort of I didn't really I have too much of a say in the process.

  • I was the, I guess, sort of the person in charge of writing down everything, compiling it, really compiling it, but running and making sure that everything went according to plan and, uh, off of that idea.

  • What if that would be really fun?

  • Really interesting is to actually take a step further than that.

  • Let us write a Python script from scratch, maybe multiple python scripts where the only thing that basically the only lines that go into the script are what the people in the chat actually end up writing.

  • And this is largely, like I said, an experiment.

  • And so I'm not entirely sure what the best way of doing this necessarily will be.

  • And maybe we'll d'oh several versions of this and we'll iterated on it and build it up and make it better and better over time.

  • The actual flow of this but today is gonna be just kind of trial and error.

  • We'll see how this works out.

  • I have an idea as to what I want to dio how I want to actually structure this, but we will.

  • We'll see if that ends up theoretically being or actions that tangibly being as good as I am thinking it will be in my head.

  • But thanks to everybody who is in the chat, we got a ton of people that they're already in here, and some people were asking if we're gonna be using a chat.

  • But for this we will not be using a chat.

  • But for this it's, I think, theoretically possible.

  • But there are some issues, especially with python being a indentation focused language people would have to write.

  • The people wouldn't need to be able to write back space and what not to like Deion Dent or shift tab, or what not?

  • And those would be considered asking escape characters, probably in the in the chat bott.

  • And so that would get a little messy.

  • But I think in theory it's possible, so we might explore that at some point in the future no promises there.

  • We'll probably do a more manual sort of curated approach in the short term, but thinks everybody is tuned in as lead bad.

  • Ignite liquid.

  • 13 Rome Ork Ah, meet.

  • Haven't seen a meet for a while.

  • Greetings from India, Some rot.

  • J.

  • P.

  • Guy came in and asked me how scared of my from us on a scale from 0 to 9 about how weird the code might get today.

  • And I'm actually not scared because we're gonna be curating everything.

  • But I think of this work completely automated.

  • It would be a little bit a little bit intimidating.

  • So here's the idea that I have.

  • The idea I have is that I will basically right in.

  • I'll have a marker, I'll say.

  • And this is just a test.

  • But all basically right in peek at you like this Whips can't type for some reason there we go.

  • A little bit of a delay.

  • So when I write Pikachu, that's like, they're ready, Set, go.

  • And then what I want people to Dio is to write in we're going to do is we're gonna kind of structure.

  • So here's my idea.

  • Here's my idea.

  • Someone switched on my computer before we actually get started out before I start writing any code.

  • But this is my project.

  • I was going to create a new file here.

  • We'll call this test one dot pie and python extensions recommended.

  • That's okay.

  • What we're gonna dio is kind of reserve slots.

  • This is my first iteration that I have because I realized if we don't do this, we run the risk of just absolute chaos.

  • Like whose code goes in front of whose code like it won't make any sense.

  • And so it makes more sense to do this kind of step by step and actually go line by line.

  • And we can't even talk about this.

  • Use this as an educational experience for some people with ABC first time joining a twitch Lifestream ever.

  • Well, you chose an interesting one to be a part of, so I hope you enjoy your time.

  • But the goal is gonna be I'm gonna say peek a chew.

  • And then what?

  • I want everyone in the chat who wants to contribute to the code, what I want them to do.

  • And this is being a little bit sluggish right now, but I want people to write in.

  • I think this is a emoji that everyone has access to the Mr Destruct oId.

  • I want three of those.

  • This is this is basically inspired by some Route 61 92.

  • He wrote that up above.

  • So whoever wants to write code as soon as I write p ca choo.

  • I want three Mr Destructor it.

  • Then what I'm gonna do is I'm gonna say Okay, so line one is going to be reserved for well, say so.

  • The true king niece.

  • What?

  • First, Right.

  • So the true kidneys gets the first line and then we'll sort of write out the list of exactly everybody's doing a great job in the chat.

  • So we'll do that.

  • We're going to structure the lines based on who writes.

  • There were three chats there.

  • Three Mr Destruct.

  • Right Emojis in the chat first.

  • That way I can visibly see very easily who wants to contribute.

  • First of all, because cold calling on people didn't seem to work to over the text adventure.

  • So I'll call on whoever wrote the three robots and will write their lines.

  • They're used names out in comments, and that way we can see line by line, who's contributed to the program, right?

  • And if we get to the end of the Mr Destructor is or whatever, we can call piggott you again and get more in foot.

  • So that was just a test because there's explaining it.

  • So we're not That's not gonna be the official set of user names yet, But whoever just contributed whoever just write your Mr Destruct Lloyd's in, Um, get ready for the for the next speaker, chew.

  • Because what I'm gonna do is I'm gonna look for my picture emoji in the chat.

  • I'm gonna go after that and start pulling the name.

  • So anything before the picture, I'm just baste again.

  • Ignore.

  • Um, Andre the ground rules is as soon as I call Pikachu.

  • If you want to contribute to the Python script, I need three Mr Destruct arrayed emojis from you because that visually going to use that as an indicator to see, um, you know who wants to contribute to the code?

  • I'm not not cold calling on people today just so that I don't put anybody on the spot.

  • And people, maybe people are busy.

  • They don't have time to come up with something on Lee.

  • People who are who want to contribute.

  • All right, so hello, guys coping And Colton's chair.

  • That's money.

  • I'm gonna go ahead.

  • I'm gonna call peek atyou, And as soon as I call Pikachu, I'm gonna put the list of names together, and then I want the list of names or put together, We're going thio one by one, line by line.

  • Go through it and build up a python program.

  • So here we go.

  • Ready?

  • Uh, 123 Peek atyou.

  • All right.

  • J.

  • P.

  • Guys first.

  • Nice.

  • So I'm gonna start putting together a list.

  • So the J P guy lips v ruthless v.

  • Ava's Shaw some rot 61 92 and murg missile.

  • Um, I apologize if I misspell your name.

  • So has are trying to make sure I catch them all.

  • We'll do this just for a minute or two.

  • We're not gonna have to.

  • Oh, did I miss disco damaged?

  • I did.

  • What's That's my bed after this go imaged.

  • So how's your injured?

  • Uh, hey, White out 16.

  • Scared to sign up for a line, and I don't even know what the program is.

  • We haven't decided what the program is.

  • That's the beautiful thing.

  • Um, m r t n c.

  • And Mr Tank Thorn in Russia at the time pronouncing the name.

  • Uh huh.

  • So we're really all in on Pokemon?

  • Uh, just using it as an indicator for today, I guess.

  • Um, Budanov, if you have ah, small problem and It's not related to the stream.

  • Just hit me up off to the side.

  • But if it's related to the stream, feel free to Ah, free Teoh Right there in the chat Babak night.

  • There we go.

  • You're doing code lines.

  • True Guineas.

  • So, uh, you will You will be telling me what you want written down in the form of a code line.

  • So you're gonna have to write the code line out, Mister Mister Tank Thorne wrote it again.

  • So we will, uh, get as many people as we can before we start taking duplicates.

  • Luigi's in the chat.

  • Shen Long Shen win is in the chat.

  • Um, that's already 12345678 That's like 11 10 Arts tent literally tunnel.

  • It's written on the left side of the text editor 10 lines.

  • Uh, okay, so if you want to start with 10 lines, that's great.

  • Okay, Shep Official Cool.

  • Shub H Official 01 That's 11.

  • When there will be a stream about problem solving checking code.

  • That time I'll post my problem.

  • Fine.

  • Try it now.

  • Test run Devil lobby.

  • Ship it.

  • This is a beautiful program.

  • So far, just a set of comments.

  • I'm quoting Project one for states 50 web, all watching this also Bunny on run.

  • I don't think they already so just didn't know.

  • Okay, No bugs.

  • You know, I that's true.

  • There are no bugs in this.

  • There we go.

  • Andres.

  • Andres gonna take part.

  • Nice cap.

  • 10 333 And pretty soon Well, actually, maybe get started on a script of some kind.

  • Now, what we could dio is we could just jump into this completely fresh, not have any goal and just let people write whatever they want, which is totally justifiable and totally chaotic.

  • Or we could decide on a goal we could say, OK, let's altogether code Mario or something like that.

  • Um, something along the lines of speller would be pretty big, but we could say something like Mario and then all work together on doing that.

  • But we could try both of them.

  • Experiment.

  • See which one's entertaining, right?

  • The whole goal of this is to be educational and entertaining.

  • Can we have a chat, Bott, today?

  • Uh, this is Bunny on run.

  • I'm not sure if you're referring to a bought that, uh I'm not sure what you're referring to with the body.

  • If you mean like, if you're asking the chat to Koda chatbots with you, um, I vote, Chaos says as Lee.

  • Okay, who votes chaos?

  • Who votes a goal?

  • Project Oiler Project early would be interesting, actually.

  • Chaos.

  • People want chaos.

  • Everyone loves chaos, all right.

  • Oh, somebody said Goal.

  • So Hauser said, Goal, my goal is chaos.

  • We'll what we'll do is we'll say it.

  • We'll do chaos first and then maybe a goal later.

  • And if this goes well, and if people enjoy this, we could maybe do this more frequently.

  • This kind of stream and maybe expand on it, add more features and whatnot.

  • But I think we have a pretty sizable list of people.

  • If we run out of people who've contributed, lines will call Peek atyou again.

  • Whoever wants to contribute can contribute.

  • But let's go ahead, and we're gonna preserve these comments because these comments are gonna help us identify sort of who's contributed to the script.

  • And we can see no who's built what as we've gone on.

  • So J.

  • P.

  • Guy, you said in the stage for this chaotic script that we're running here, so you go first tell me what it is like You get blamed.

  • Yes, 80 Dominate.

  • Hello.

  • Good to see you.

  • S O J P.

  • Guy.

  • Let's get the first python line.

  • Any of you aren't familiar with Python?

  • This might be more difficult if you've volunteered.

  • Thio, contribute.

  • Okay, so we have a function.

  • Ah, function.

  • Signature declaration Check.

  • Okay, I like it.

  • So this is a beginning of a function from people who aren't familiar with Python.

  • So, uh, this is interesting.

  • So the ruthless V And if you, by the way, if you want to get out of a block of an indentation block, let me know and then 80 dominate.

  • Yes.

  • I'll put you down here at the bottom of the rules.

  • 80.

  • Dominate our that.

  • I'm gonna call Pikachu, Basically, which means put the picture emoji in the chat.

  • And anybody who wants to contribute to this script needs to put three of those robot destruct oId emojis you should have access to.

  • It is a general twist user, but be ruthless.

  • V.

  • Let's get your line as line number two and again.

  • If you want to come out of the oven nested block, let's say we're in a function.

  • You want to come out of the function, just specify.

  • Wow.

  • One print.

  • What?

  • We have the first troll today.

  • So we haven't called the script the function to be fair.

  • So while one print what?

  • Beautiful.

  • And I'm just gonna invent these all nicely like that.

  • So there we have our first beautiful function, so that's V dominate.

  • Sorry.

  • Be ruthless, V.

  • Um, And now Abby Shawl at Michelle is gonna be the next person to contribute to Abby.

  • Shawl.

  • Let me know what you want to d'oh to this python script.

  • This beautiful python script that we have so far I'm gonna keep it on, um, on this break.

  • Okay, so So they have a break.

  • Interesting.

  • Now, do you want the brake?

  • Uh, right here.

  • Where do you want the break, Abby Shell.

  • Can you be more specific for me?

  • Show official says I see where it's going.

  • It's kind of devolving into Ah, an infinite cess pool of ah, inside the while.

  • Okay, so the issue with that is gonna be we're going to do something like this because that is not possible.

  • So that semicolon there, I'm guessing that's where you're what you're going for, uh, so we'll do that.

  • So we'll say, Uh, oops.

  • Today did a ago.

  • So there might We might need to specify a rule, which is that you can't have one liner loops And if statements because that causes issues like this where, um, the ruthless V sort of put us into an infinite loop, and then we had to use the same line with Abby Shell to correct it.

  • I mean, we can experiment with it and see and see, you know where things need to go.

  • But, you know, whatever it works, it solves the problem.

  • It's just gonna get a little bloated.

  • I like the idea of having one line per person, not like one line.

  • That's like conglomerated, that's multiple.

  • People are sharing, but, you know, good save on officials on officials parte eso sombra 61 92.

  • If we could get a line of code from you, and actually, why don't we say that as a rule, maybe so that we can keep people on the same line, keep people on individual lines So we'll say this will say that this is vey ruthless is And there we go.

  • This air will do this.

  • Boom!

  • Bring this up here.

  • So, technically, this is not one line from be ruthless, but where it will retroactively make it work.

  • So there we go.

  • So some raw 61 92.

  • Let's get your your next line.

  • Oh, yeah.

  • I mean, if you want to contribute, I'll put your name at the bottom of the script here.

  • So, um, meet Microsoft India.

  • All right, so some route 61 92 Let's get a, uh, okay.

  • Where would you like, uh, Do you want it?

  • So here's the thing.

  • Do you want it here in the same, By the way, this indentation is killing me.

  • Here we go.

  • Sorry.

  • This indentation got messed up for some reason.

  • Bring that back.

  • There we go.

  • And here we go.

  • And then summer.

  • Okay, So some rot wanted the What was it?

  • Oh, OK.

  • Print chat is lovely.

  • Now, did you want it there some rot?

  • Thio, tell me where you want the cause.

  • If you don't specify an indentation like you want to come back out of the indentation.

  • This is different from putting it.

  • For example, back here.

  • Why is this invitation makes a terrible there we go.

  • You're ruthless.

  • But at least I got the council to print.

  • What wants?

  • Should have thought about something funnier than what l A Well, uh, Joker kids is Hello.

  • Not looking to participate, but I usually watch these videos on YouTube and wanted to come here to say they're awesome.

  • Thank you so much.

  • If you feel inclined.

  • Thio participate.

  • Definitely.

  • Definitely.

  • Consider doing it.

  • Um Oh.

  • Sorry.

  • I'll be Tek 18.

  • Let me go ahead.

  • I'll add you.

  • Uh, b Tech 18.

  • Okay, So you want you wanted.

  • The chat is lovely Line right there.

  • Perfect.

  • Okay, cool.

  • So, uh, murg muscle.

  • Um, let's get the next line from you, Lucas.

  • Nothing's has Add me.

  • Okay.

  • Cool.

  • Can do that.

  • Have an endless endless supply of people.

  • This makes our chat easier.

  • Thio prolong.

  • Certainly.

  • Um And if I if I missed anybody, I apologize.

  • Let me know.

  • Actually, if you want to get added, and I haven't added you yet.

  • This is the This is the way to indicate it.

  • Exactly.

  • A stricken.

  • He said, uh, lagging a little time.

  • But come on.

  • Here we go.

  • If you want the If you want to participate and I haven't added yet.

  • Just write this in the chat, the three robots that I can visually see that very easily compared to reading all of the all the stuff in the chat.

  • Okay, Kedra boss.

  • And I believe we're still waiting on s ome.

  • Urgh!

  • Ah, Salam.

  • Did you want to contribute to add myself to the list?

  • Okay, sure.

  • I'll add myself off myself right here, Uh, down way at the bottom.

  • Um, murder muscle.

  • Um, we need a line from you, and we'll time this out.

  • So we'll say if nobody contributes a line within, like, a minute, then, um Oh, true.

  • Yeah.

  • That line will never be Well, I asked.

  • I asked some Rod, if you want it is not here.

  • She wanted their line there.

  • So, you know, I They said they wanted it there, but yeah, I think technically speaking, this is the only way it will actually be visible.

  • So we probably want that we probably wanted there, uh, should add Colton's hair color for us.

  • They're kind people in the chat.

  • That may help explain the rules.

  • True, I do appreciate anybody who's willing to do that for me.

  • Um, I think we're still waiting on.

  • So merge Ma Salam.

  • So what I think we might end up doing is if the person who, uh, put their line in doesn't end up actually writing it, I'll sort of take their name out and put it back towards the bottom.

  • So we'll do that.

  • We'll just bring this back down here.

  • So murder muscle, um, can contribute a little bit later.

  • Some folks are gonna come in and out, which is natural.

  • So it's it's I think that's okay.

  • Disco damage, though.

  • Europe, You're next on the line.

  • So give me your next.

  • Give you what you want the line to be.

  • And, uh, if you want.

  • Here's what What?

  • I think the, um so disco damages Writing a combo statement on one line.

  • Um, which is basically saying if Mario is great and Bowser print the princess's saved else prints.

  • Sorry, that princess is in another castle.

  • The problem is that that makes it hard for us too.

  • That give it that makes us susceptible to infinite loops that we can't break out of and can cause compound issues that are hard to solve.

  • So what we're gonna do is we're gonna only allow for if you have an if statement, just the if statement.

  • So you can't have Lycan if than a block, then in else than a block, Because python could let you chain a bunch of stuff on a one line.

  • So just one condition, one block, one condition, one blocker or ah, loop header on Lee that only that for your for your bit of cut.

  • Okay, Perfect.

  • So another thing, what we're gonna need people to do is specify their indentation.

  • Because, you know, I could put that line here, or I could put it here, and those would have two different effects.

  • So do you want your if statement here, or do you want it back and back?

  • An indentation?

  • So for the folks that are contributing from now on, if you're gonna give me a line, say either same indentation, nested indentation or back indentation.

  • So go in, stay at the current level or go back for indentation.

  • Disco damage says go back for indentation.

  • So we're going to say, um, if Mario is, uh, I gotta go back and read it now.

  • Greater than Bowser.

  • Now, um, some folks in the chat already, um already told us that this is gonna be a problem because there is nothing defined as Mario or Bowser.

  • So that's just gonna break the code we can.

  • We can add something.

  • We can add a body to that.

  • If statement if so, has or wants to contribute so house or feel free to contribute, let's run this and actually, uh, maybe test it so we can see exactly what the problem is.

  • But next line is so how's or so so how's?

  • Or if you're in the chat, then let us know.

  • Zucchini says, Can you compare strings?

  • Yes.

  • You absolutely could compare strings 100%.

  • Um, that would be different.

  • Ah, different set of behavior than what?

  • Um, disco damaged.

  • Ended up proposing CS 50 equal 69 69.

  • Okay, so C s 50 equals 6969 So that's a legal statement, though, right?

  • That's that's completely illegal.

  • It's a, uh it's just assigning an integer value to a variable called CS 50.

  • And it's a legal variable name.

  • Um, the only problem is gonna be this bit of code here.

  • So what we can do is we can actually run this code and I'm gonna do that right now.

  • I'm gonna bring up in my terminal and let's make sure I'm in the right place.

  • So it's going to Dev Streams.

  • This is called chat codes Python.

  • And then I'll just run test one dot pie and you can see that, um, here in the in the terminal.

  • It's telling us Python is telling us, Hey, the name Mario is not defined Like that's not a variable that exists anywhere.

  • So we're gonna kind of need to get away from that issue.

  • Hard up, Raj.

  • I'll add you to the list of contributors here, So let's go ahead and say that right here.

  • Now let's add a new rule.

  • People can propose an amendment.

  • So here's that's N S F w s.

  • Oh, well, say if people, if you're contributing, I want you to write Amendment like this and then blah, blah, blah, blah, right?

  • So if you want to correct somebody's line, say Amendment, actually here say Amendment Line seven and then blah, blah, blah, blah.

  • So this is a good good opportunity for somebody who wants to fix our code.

  • I propose important West.

  • Have fun chat.

  • You have hunting.

  • We're already in the global scope?

  • Yes.

  • As to what Merlin said, we're already in the global scope.

  • Any anything.

  • Any code that we right here is global.

  • Any variables we assign so on and so forth.

  • True Guineas Wants Thio contribute again.

  • Um, actually, no.

  • Did We didn't write true Guineas in here for this batch today.

  • We didn't allow.

  • The truth can be stricken.

  • East was the first person to propose code with the original mock batch, but that didn't end up.

  • They didn't end up going anywhere.

  • And then v zero Elko.

  • So go ahead and write that.

  • So v zero Elko.

  • So who's the next person?

  • Hey, why 0.16 s so sorry.

  • My network was bad.

  • Okay, that's okay.

  • Totally understand.

  • If you want to propose a change, why dot Let's go ahead.

  • And, uh, let's go ahead and take your input.

  • Let's see what you can.

  • D'oh ifit's a proposed amendment Or just keep this awful sort of script.

  • And not to say it's awful.

  • It's a beautiful script, but it's broken.

  • We need to fix it somehow.

  • Um, so hopefully somebody can propose an amendment to how we can fix this script.

  • Can I play Caro five.

  • Absolutely.

  • I'll add you to the list.

  • So Cairo five.

  • We're taking individual requests.

  • Um, do you know those twitch place dreams?

  • I absolutely do This actually sort of inspired by that.

  • The less automated.

  • If this were automated, it would get pretty pretty insane.

  • But I think could be interesting to try it at some point.

  • Burn it says murder.

  • Do you have three times?

  • If you want a coat, a line trick.

  • Unease.

  • I appreciate you know, I should have a bott that actually says that truth.

  • Keyes has been on top of helping out.

  • Um, I feel like it would be nice to have Ah, cool.

  • Little bought that reminds people howto how to do that because that's that's pretty nice.

  • Um, so hey, wideout 16.

  • If you're okay, I propose.

  • While one should have less than or equal to.

  • Okay, that's fair.

  • So while one is less than or equal to what and, uh, ideally, follow, the, uh, so hazardous has proposed from line six.

  • Bowser is to line seven for Mario in range.

  • Well, one is less than two.

  • Merlin.

  • Yeah, I like that.

  • Um, all right, so why DOT said while one is less than or equal.

  • Thio, right is already said less than or equal to.

  • And we're gonna need less than or equal to something right that needs tiu less.

  • They're equal to expect.

  • It's an operator that expects to operandi one on the left and one on the right or reverse if you're looking at me on stream, uh, Merlin proposed to so we can use to if, hey, why dot is okay with doing that.

  • Um, so we'll say Amendment.

  • Actually, what Will dio is amendments will go above amendment, uh, less than or equal to Hey, why dot to what was the name 16 Probably won't want one is less than 10.

  • Okay, one is less than 10.

  • So that's effectively, uh, the same logic, right?

  • It's the same.

  • It's gonna do the same exact thing.

  • A a an infinite loop.

  • Because one is always less than 10.

  • And one is always a truth.

  • The value, while one basically just means while true, we can effectively think of it that way.

  • So why dot proposed an amendment here above this line.

  • So awesome.

  • Now, let's go ahead and get Mr, uh, Mr Tank Thorne.

  • If we could get Mr Tank Thorne to give us the next line in the code being an amendment or a new line.

  • Just specify where, exactly want your code and and how we're going to use it.

  • Break though.

  • We did use break.

  • Yeah, break helped us get out of the infinite loop.

  • Thank goodness for, uh, official who proposed that for us.

  • Um, Andre, you're gonna have to wait your turn.

  • I'm afraid, but definitely you can propose stuff.

  • Actually, this is fine.

  • So if you're proposing things in the chat, that's totally fine.

  • I just won't consider it.

  • If your name is not the current person, just cause then it'll get chaotic and whoever comtech fastest sort of winds.

  • But you can use that as it may be a way to get inspiration.

  • So it's easy.

  • Just don't run the chat coats python function.

  • Exactly.

  • You can propose suggestions for people or write stuff, and people that are whose turn it is can maybe fall on those suggestions.

  • But we won't consider any lines unless it's that person's turn.

  • So we want We want fairness.

  • In this particular example, Kanosh has a proposal for line eight.

  • We get advantage on a nine with advantage.

  • I was gonna call that fun.

  • L o l You know, we could We could try that it would get very difficult Thio.

  • It'd be very difficult to keep track of for me because I would have to sort of, like, constantly roll back up the chat on do stuff, and it would get.

  • And obviously, people stuff would be out of order, and they'd be writing over each other and sort of writing on the same line.

  • So that's kind of why we're doing more of a take a turn approach to the script and proposing amendments, So we'll see.

  • But Mr Tank Thorne is up currently.

  • We'll tow take just a few seconds.

  • And if Mr Tink Thorne doesn't respond, well, call on Babak for the next line.

  • So Babic is the indeed the next person loner.

  • Kingston's got in a minute line.

  • Oh, Mario Ziegel to heart Emojis like that.

  • Mr.

  • Tank Thorne is not available.

  • Okay, that's fine.

  • We probably have, like, maybe 15 20 people in the queue.

  • Um, So, Mr Tank Thorne, we're going to, uh, take your name saved what we're gonna do instead of rolling back names to the end of the list for its gonna delete names.

  • And if you want to get added, just use the three robots again.

  • This is an experiment where this is the first time we've done this.

  • So this might be a little bit sloppy until we build up a really good system and demo pathos.

  • Just write three robots in the chat.

  • Since you already wrote as much, I will add you to the end here.

  • Um, that just makes it very easy for me to visibly see who wants to who wants to contribute.

  • So I don't have to read every line on and re read it and just double check that I missed anybody.

  • I could very easily see the green big robot on the screen so bad ignite, Babak, it's your turn.

  • Let me know what you want to add to the script if you want an amendment.

  • If you want a an individual line, make sure to specify your indentation, too.

  • And remember, we can't do compound lines were doing If you If you want an if statement or a wild statement or four statement, just make sure that you only do the four of the while or whatever.

  • Don't do like a chain list of stuff.

  • Just cause then it's really hard.

  • It's really easy.

  • Thio fall into a hard to amend mistake.

  • Uh, someone notify me in the chat with my turn comes absolutely as Lee T.

  • I will happily add you to the end of the queue.

  • Loner Kington actually asked before.

  • So let me go ahead and do that loner Kington and Amendment Line nine.

  • If Mario there we go back, fix the script.

  • So we're gonna say amendment with, uh, havoc night.

  • And so what Babic date is these air two variables right now because they don't have quotes around them.

  • Any word that's not a python keyword is considered a variable, but we haven't assigned anything to those names.

  • But what Babbitt's done is, Babacan said, okay, instead of that, let's just say if Mario is less than, uh, CS 50 right?

  • And so what that's done is now we've taken what these air called string liberals.

  • So these are just pieces of data strings and you can compare strings against strings.

  • It'll base ago letter by letter, seeing which one is less than the letter in the other words.

  • So it'll compare the M to the sea.

  • The sea is gonna be less than the M.

  • So CS 50 is gonna evaluate to being less than Mario.

  • If they both started with the sea, it would go to the second letter of the words and then therefore perform the same kind of arithmetic.

  • Um, so can ah Zhu.

  • I wanted to get added to the script, So let's go ahead and do that knowledge so excellently done by Babic night.

  • Let's go ahead and run our script and see what happens, and nothing happens.

  • And this is good.

  • This means our script ran successfully.

  • There were no bugs.

  • We didn't get a a trace back like we did earlier because it said, Mario is not defined.

  • Now our script just runs.

  • All it does is if Mario was less than CS 50 which it's not, then CS 50 is gonna There's gonna be a variable in this scope called CS 50 which gets a sign the numerical value of 69 69.

  • So, um, nice amendment on Babbitt's part.

  • We have a working, working script.

  • So next person that we want to get onto the script ship official.

  • 01 Let's get a Let's get a, um, suggestion from you.

  • Let's see what you got.

  • What you gonna add to this script?

  • Let's make it.

  • Let's make it awesome.

  • I'm very curious where we're going to get from here.

  • Print different strings.

  • Now, where do you want this?

  • Shub?

  • So remember, we're gonna We're gonna assume there are cursor is always sort of where our current line is.

  • So our cursors here do you want at present indentation, or do you want it back?

  • An indentation?

  • Those are two different options.

  • They have two different results.

  • Print different strings.

  • Okay, so we want it.

  • I'm gonna assume that we want it here in the current scope, but this is sort of where you need to be specific, because those have two different behaviors, right?

  • So shove official said print, uh, different strings and going to go back over here Now, I wouldn't necessarily say that that logic is sound.

  • Well, actually, yeah, it actually is.

  • Sounded this sound logic.

  • They are different strings, because if one is less than the other one, they have to be different strings.

  • So I correct that statement.

  • Um, it isn't necessarily The logic doesn't necessarily test for different strings as much as a test for one string being of a different quality than another string.

  • It's kind of like a It's kind of like an over generalized statement, but it makes sense.

  • People voted chaos called respect the democracy.

  • No, this is this is Ah ah.

  • I like this so far.

  • I want this to be a chaotic, But we, uh I want people to also be specific about where where things get put.

  • Um, cool.

  • So shove official.

  • Thanks for the contribution.

  • If we run this script, we see that it actually doesn't say different strings.

  • Interesting.

  • Why is that?

  • Is Mario actually not less than CS 50?

  • Oh, no.

  • Margo's sorry Mario is greater than CS 50.

  • So this is this isn't gonna run, right?

  • Way said that before, but I had a brain fart.

  • Um, it should be not equals there this.

  • Well, if you want to change that, you need to propose an amendment show.

  • So we're gonna have to have somebody else decide on that because you're you did this line.

  • So if somebody wants to correct that, they're more than welcome to do so.

  • But it's devil lobbies Turn to propose a a change to the scripts.

  • The devil lobby.

  • What do you propose that we change about our Python script?

  • Shep officials saying, huh?

  • Yeah, it's, You know, we can, uh we gotta respect everybody's contributions.

  • You know, we can't dio we can't override all you know everything sort of have passively, captain.

  • 333 things for the follow anybody else's followed today.

  • A part is if I missed it, uh, much appreciated.

  • We had a ton of followers yesterday as well That I I didn't specify.

  • Ah, there we go.

  • She devil aby is ah is on shoved aside.

  • So, amendment, if Mario is not equal to CS 50 So something like that, which is great.

  • So I'm going to add Devil Abi's name here to the amendment list for this line and let's save it and run it.

  • And we do indeed see the different strings thing.

  • Let's let's let's do it.

  • You're missing a quote, but let's roll with it.

  • You know, I'm also sort of here to account for people's typos.

  • I feel like that would be even.

  • I feel it could be even worse to go full chaotic and then take typos into consideration.

  • Um, I don't know if people wants to want me to be pedantic about, like, typos like that.

  • It be interesting.

  • It could be frustrating for some people to watch, but that's that's I mean, that would technically be programming.

  • So have we reached the Fifth Amendment yet?

  • No, this is s so far, we're at three amendments.

  • So bunny on, run your turn.

  • Let's see what we got.

  • Molik the law in 1987 of the world.

  • Good evening.

  • Uh, so as this is, I don't know where it's going.

  • This is the beauty of this, though we don't know where it's going, and that's okay.

  • I think that's that's why this is fun.

  • For the love of all that is Holy someone in port anti gravity says Andre.

  • Hey, Andre, When it's your turn, you have every every right every prerogative to import anti gravity.

  • Oh, geez.

  • Okay.

  • Well, this is cool.

  • Okay, so, bunny on run.

  • Where do you want that?

  • In the script.

  • You want the very fancy.

  • I like the list comprehension.

  • Um, that's also the problem is that we're using Python three.

  • So we're gonna actually get put in a parentheses around that, but that should still work.

  • It'll just print out the list.

  • Has a list if you want to.

  • D'oh.

  • I think, Yeah, I think you would need the print actually be in the list.

  • Comprehension in the in a specific place outside the If.

  • Okay, so this is cool.

  • I like I like what?

  • Buddy on Run's done a little bit more of an advanced feature of python of the list comprehension.

  • But basically, bunny on run has said, um, prince a B for a in CS 50 whips CS 50 uh is and then, uh, Colton is, and then space there in the space there and then for be in, uh, great.

  • And then amazing.

  • So very, very flattering.

  • So if we run this, we will see that we get a sort of a combination of the CS 50 is great, and seafood is amazing.

  • Well, rather, CS 50 Colton is great and amazing.

  • We get CS 50 is great.

  • Amazing and coldness, great many ways in which, thank you very much for the kind words.

  • And CS 50 is very flattered as well, I'm sure, but this is the output of that so pretty cool.

  • I'm a big fan of that.

  • Um, you could probably find a way Thio.

  • If you weren't a map prints to that, you could probably end up instead of printing the list itself.

  • You could actually print the strings themselves in a list, but, um, I would have to.

  • Is that would it be possible?

  • I think you could do that.

  • You could do map with a Lambda on X for every exit list comprehension.

  • Instead of printing the list out right, I think that would work.

  • So be cool.

  • Yeah, Very nice.

  • Contribution by Bunyan run.

  • Thank you very much.

  • Uh, anybody unfamiliar again?

  • This is called a list comprehension, and this is actually a nested list comprehension.

  • So to list comprehension is in one which allows you thio sort of do a two dimensional loop over data.

  • Pretty cool, Andre.

  • It's your turn.

  • What are we gonna do, Andre?

  • Gonna import anti gravity?

  • I want to see it.

  • I think the chat wants to see it.

  • But if you'd rather do something fancy instead, definitely let me know.

  • And make sure to specify where you want to import anti gravity too.

  • No, we have to be organized, says entree.

  • All right, Andre.

  • Let's see what we see.

  • What you want to.

  • D'oh!

  • Oh, okay.

  • Perfect light.

  • Why wants to contribute?

  • I apologize if I missed anybody.

  • I don't think I did.

  • Who wanted to contribute to the chat?

  • So don't the very bottom we're gonna say, Uh, l one GHT underscore.

  • Why?

  • So you will be after can AJ, if name is equal to Maine.

  • Oh, boy.

  • Here we go.

  • Okay.

  • So, Andre Andre wants us to get, uh, more organized with our codes.

  • Were going to say if name is equal to, uh, quotes underscore underscore Main are scoring a score just like that.

  • Boom.

  • So for folks unfamiliar, this is the way that python modules, python scripts sort of checked to see if they're being run as the main script at the command line or whatnot.

  • So this is this basically is going to get, uh, started.

  • And then whatever's inside of here will get run if this script is being run into command line.

  • So anything in here?

  • If this were being used as a library file, nothing inside of here would get run so effectively.

  • All of this stuff is kind of like the same as if we put it in here for all intents and purposes, um, but, you know, we have it there.

  • We have it there now, as a formality, Our script now looks more legitimate.

  • Uh, what have you So, Captain, 33 3 Let's go ahead and get a line from you.

  • Very excited to see where we go from here.

  • New line.

  • No indentation.

  • Input key is input.

  • Death press F to pay respect key.

  • Okay, Interesting.

  • Um, okay.

  • Uh, the one thing is that this is going to break, but that's okay, because there's nothing inside the if statement, but we'll say input key is equal to input.

  • Death press F to pay respect key.

  • Um, I don't think this will work.

  • I think this I think this will just break right because you can't have ah, death on the same line as after an input without a semi colon are.

  • But we're not doing nested lines, so I'm not sure.

  • Yeah, we can't work, Captain.

  • We're not doing nested lines, so if you have multiple things you want to do, you can do this, for example, So input key is equal to input but to save us the ability for people to mess with stuff and to cause hard to debug stuff, it's going to we're going to just do a single lines.

  • So do you want to do one to input his input?

  • You can revise your, uh, your line, if you would.

  • Like.

  • Chef says this is gross.

  • Yeah, but that's kind of the point.

  • That's, uh, okay, just input.

  • Okay, great.

  • So input key gets input so that what that's going to dio is if we run this script now Well, first of all, it's gonna break because, um, there's an indentation or not.

  • There is no indentation block here with any information.

  • So Andre said if name is equal to Maine, and then Python expects there to be some stuff here, If there's nothing here, it freaks out.

  • Because the next thing that it sees is this line that's at the same level of indentation as that.

  • If statement and that's an error in python, there needs to be an indented something here, even if it's just past like that.

  • Right?

  • Um, so we're going to fix that at some point.

  • If anybody wants to be the person to fix that, but a t t dominate.

  • You are the next in line, so let's get a, uh, let's get some input from a t t dominate Amend Line 19 pass.

  • And that's not even an amendment.

  • Honestly, that's just that will just be your line.

  • So we'll go ahead and well, add that here.

  • Ah, actually, I realized for consistency.

  • This needs to be like that, and I put money on runs name up above here, just cause it's a very long name, but for the shorter are long line of code, but for the shorter lines of code, we'll just we'll just put it off to the side so people can see at a glance who contributed, and we've got a lot of contributors so far today.

  • So now if we run this code, this should work.

  • So this is great notice that it didn't end the script right?

  • We see the bunny on runs list comprehension printed out to the screen, but the consul is sort of still

I'm still feeling like someone's with me.

字幕與單字

單字即點即查 點擊單字可以查詢單字解釋

B1 中級

CHAT寫了我的PYTHON程序!- CS50 Live, EP.54 (pre-release) (CHAT WRITES MY PYTHON PROGRAM! - CS50 Live, EP. 54 (pre-release))

  • 1 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字