1 00:00:00,000 --> 00:00:09,496 [MUSIC] 2 00:00:09,496 --> 00:00:11,530 Well hello there, Craig here. 3 00:00:11,530 --> 00:00:12,890 How's it going? 4 00:00:12,890 --> 00:00:16,740 In this workshop, we're gonna practice using some of those python muscles that 5 00:00:16,740 --> 00:00:18,100 you've been building up. 6 00:00:18,100 --> 00:00:19,910 When you're just getting started with the language, 7 00:00:19,910 --> 00:00:24,520 sometimes it's hard to find a way to apply the skills that you've been learning. 8 00:00:24,520 --> 00:00:27,580 It's hard to see how the pieces that you've been picking up all snap together 9 00:00:27,580 --> 00:00:28,840 to form a program. 10 00:00:28,840 --> 00:00:32,830 Now I'm going to assume for this practice session, that you know how to use 11 00:00:32,830 --> 00:00:36,920 variables, take input from a user and output things to the screen. 12 00:00:36,920 --> 00:00:39,170 If you don't, please check the teacher's notes for 13 00:00:39,170 --> 00:00:40,440 where you can learn those things. 14 00:00:41,580 --> 00:00:45,370 Believe it or not, but with just those skills, input, output, and 15 00:00:45,370 --> 00:00:48,540 variables, you can write a pretty fun game. 16 00:00:48,540 --> 00:00:53,200 Now, I'm not sure if you've done one of these before, but 17 00:00:53,200 --> 00:00:56,290 Mad Libs has been declared the world's best word game. 18 00:00:57,690 --> 00:00:59,080 The way it works is this. 19 00:00:59,080 --> 00:01:02,190 There's two players, and one player has a page like this. 20 00:01:02,190 --> 00:01:05,260 And see how it has blanks that are labeled with different parts of speech like 21 00:01:05,260 --> 00:01:07,650 a noun, an adjective, or a verb? 22 00:01:07,650 --> 00:01:10,300 The first player prompts the second player for 23 00:01:10,300 --> 00:01:14,620 words that match those parts of speech and fills in the blanks with their answers. 24 00:01:14,620 --> 00:01:19,430 Then the first player reads the results aloud and hilarity ensues. 25 00:01:19,430 --> 00:01:20,800 So we're gonna do it. 26 00:01:20,800 --> 00:01:23,260 We're gonna build MadLibs in Python. 27 00:01:23,260 --> 00:01:24,760 So let's go back to the workspace. 28 00:01:24,760 --> 00:01:28,750 Go ahead and launch this and you will see here I have a file called madlibs.py. 29 00:01:28,750 --> 00:01:29,620 So I'm gonna open that up. 30 00:01:31,960 --> 00:01:35,250 And you'll notice here that I've made a template for us. 31 00:01:35,250 --> 00:01:39,610 Something that you might not have encountered yet are these pound signs or 32 00:01:39,610 --> 00:01:42,330 hashtags, as the kids are calling them these days. 33 00:01:42,330 --> 00:01:44,445 What this does is this is a comment, and 34 00:01:44,445 --> 00:01:48,540 this tells Python to ignore all of the characters on the line and after it. 35 00:01:48,540 --> 00:01:54,900 So what we can do is we can use this to write English, just like I did here. 36 00:01:54,900 --> 00:01:57,780 It's a way to be able to communicate to readers of your code. 37 00:01:59,000 --> 00:02:01,100 You'll end up leaning on these quite a bit in the future. 38 00:02:02,460 --> 00:02:06,770 Comments can also be used to make note of things that you'd like to do later, 39 00:02:06,770 --> 00:02:08,220 sort of like a to do list. 40 00:02:08,220 --> 00:02:09,560 And typically the way that you do it, 41 00:02:09,560 --> 00:02:13,230 kinda the format that's come about is this to do, in all caps. 42 00:02:13,230 --> 00:02:15,480 TODO colon and then what it is. 43 00:02:15,480 --> 00:02:16,820 It's kinda like a standard. 44 00:02:18,190 --> 00:02:22,360 So I've left some to do's for you to do. 45 00:02:22,360 --> 00:02:27,575 But first off, I'd like you to prompt the user for the various parts of speech, 46 00:02:27,575 --> 00:02:32,030 like the verb and the noun and the adjective. 47 00:02:32,030 --> 00:02:34,690 And then store each of the responses in a variable. 48 00:02:35,980 --> 00:02:40,400 And then the second to do, I would like you to output 49 00:02:40,400 --> 00:02:43,640 that template with the words that the user just filled out. 50 00:02:44,800 --> 00:02:45,720 Got it? 51 00:02:45,720 --> 00:02:47,810 Don't worry, you got this. 52 00:02:47,810 --> 00:02:52,360 You have all the skills that you need to achieve this, and it's totally fine for 53 00:02:52,360 --> 00:02:53,960 this to be a bit of a struggle. 54 00:02:53,960 --> 00:02:57,850 It's kinda like no pain no gain, but for your brain. 55 00:02:57,850 --> 00:03:00,990 So in the next video I'll show you how I did it. 56 00:03:00,990 --> 00:03:02,500 In fact, you know what? 57 00:03:02,500 --> 00:03:04,280 I've already done the practice, so 58 00:03:04,280 --> 00:03:07,810 let me show you what my final product looks like so you can try to recreate it. 59 00:03:07,810 --> 00:03:09,270 So here, I'm gonna jump over to mine. 60 00:03:09,270 --> 00:03:12,130 I'm not going to show you my code, nice try. 61 00:03:12,130 --> 00:03:15,630 So say python and the name of that program is madlibs.py. 62 00:03:15,630 --> 00:03:17,880 So this is what it looks like when it runs. 63 00:03:17,880 --> 00:03:18,950 So it says, please enter a verb. 64 00:03:18,950 --> 00:03:20,660 Now remember I don't know what that template is. 65 00:03:20,660 --> 00:03:23,870 So dance, I don't know. 66 00:03:23,870 --> 00:03:25,930 Enter a noun, let's see, dinosaur. 67 00:03:25,930 --> 00:03:27,170 That's a good noun. 68 00:03:27,170 --> 00:03:28,550 And an adjective. 69 00:03:28,550 --> 00:03:30,510 How about wacky? 70 00:03:30,510 --> 00:03:34,320 I enjoy practice, I find it helps me to dance better, I wish. 71 00:03:34,320 --> 00:03:36,890 Without practice, my dinosaur probably wouldn't even work. 72 00:03:36,890 --> 00:03:39,060 My codes gonna get more wacky every single day. 73 00:03:39,060 --> 00:03:41,170 See, fun, right. 74 00:03:41,170 --> 00:03:43,320 All right, so you can do this, right? 75 00:03:43,320 --> 00:03:46,620 And again, don't beat yourself up if you can't quite get it, 76 00:03:46,620 --> 00:03:48,410 I want you to really give it a try. 77 00:03:48,410 --> 00:03:50,910 And remember, I'll show you how I did it in the next video, but 78 00:03:50,910 --> 00:03:53,890 don't skip ahead, give it a go, you ready? 79 00:03:53,890 --> 00:03:54,840 You got this.