Python for Absolute Beginners Transcripts
Chapter: Organizing and reusing code with functions
Lecture: Practice time!

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now that you've seen the power of functions both for re-using code allowing you to work on it in one place but affect it in many places that it's used
0:08 in your program and treated as a black box. Just, here's a core idea that may be complicated but all you got to think about is what goes in
0:17 and what comes out, for example, check for winning throw. That was super complicated, but we just passed in the plays and got the winner back.
0:24 That was nice so let us think about our program in a much higher level. So, I put together some practice exercises for this chapter, as well.
0:32 I think you'll have a lot of fun wit this one. A pair of core concepts that are very close to each other and that's just about creating functions.
0:38 Here's a function that takes a parameter and uses it. Here's a function that has a return value it gets the data internally creates it
0:47 and then gives it back. And we can even use these together like we can use the get name one to actually get the name
0:52 and then to say hello to greet the person after they've given us their name. So, here's a couple ways in which we can do that.
0:59 For this exercise, your job is to take the M&M guessing game which you'll recall it was written with no functions
1:06 just all jammed together created back in CH05 before we talked about functions. And clean it up, using functions. Now, if you look in this folder
1:15 in practices, CH06. You can see there's a copy this. I put it here just to make sure that it's right here and easy to get to.
1:23 If you go here, you can see it's doing things like printing out what the game is some information. Getting some random details.
1:30 Playing some rounds, checking for a winner. These should all sound kind of familiar. And you could use functions to make it a lot nicer.
1:37 So, that's your job, take this code make a copy of it somewhere make it better with functions.

Talk Python's Mastodon Michael Kennedy's Mastodon