1 00:00:00,260 --> 00:00:04,084 Okay, so there's a new workspace attached to this video, and I'd like for 2 00:00:04,084 --> 00:00:04,997 you to launch it. 3 00:00:04,997 --> 00:00:10,091 It has a single file in it called masterticket.py. 4 00:00:10,091 --> 00:00:12,751 It's not trademarked, is it, masterticket? 5 00:00:12,751 --> 00:00:17,207 This file has a single constant defined, TICKET_PRICE. 6 00:00:17,207 --> 00:00:19,587 $10, that's very reasonable. 7 00:00:19,587 --> 00:00:22,804 There's also a counter that is called tickets_remaining, and 8 00:00:22,804 --> 00:00:25,385 it's been set up to have 100 tickets available. 9 00:00:25,385 --> 00:00:27,919 Now that's a pretty small and intimate space. 10 00:00:27,919 --> 00:00:30,028 Let's say we grab the first user story here, 11 00:00:30,028 --> 00:00:33,136 of as a User I should be shown the number of tickets left remaining so 12 00:00:33,136 --> 00:00:35,374 I can understand the importance of buying now. 13 00:00:35,374 --> 00:00:38,320 I'm gonna put that In Progress. 14 00:00:38,320 --> 00:00:41,539 So let's flip back over here. 15 00:00:43,852 --> 00:00:46,305 I'm gonna make a comment for us. 16 00:00:46,305 --> 00:00:51,145 So we want to output how many tickets are remaining, 17 00:00:51,145 --> 00:00:57,745 using the tickets remaining using the tickets_remaining variable. 18 00:00:59,383 --> 00:01:01,006 All right, we can do that. 19 00:01:01,006 --> 00:01:02,889 Here, I'll tell you what. 20 00:01:02,889 --> 00:01:06,106 I'll pause and why don't you write this output statement. 21 00:01:06,106 --> 00:01:09,868 And after you get it, unpause me and I'll show you my implementation. 22 00:01:09,868 --> 00:01:10,704 Are you ready? 23 00:01:10,704 --> 00:01:11,917 Pause me. 24 00:01:12,956 --> 00:01:15,459 Here's how I did it. 25 00:01:15,459 --> 00:01:19,716 So, I'm gonna print("There are {}, and 26 00:01:19,716 --> 00:01:25,403 I'm gonna use string formatting, tickets remaining.". 27 00:01:25,403 --> 00:01:29,825 And I'm gonna format and I pass in the tickets_remaining variable. 28 00:01:31,993 --> 00:01:34,599 Awesome, well let's flip to Trello. 29 00:01:34,599 --> 00:01:35,988 We've already got one done. 30 00:01:35,988 --> 00:01:37,929 This feels pretty amazing, doesn't it? 31 00:01:37,929 --> 00:01:39,171 Okay, so next step. 32 00:01:39,171 --> 00:01:42,074 Let's grab this personalized experienced one. 33 00:01:42,074 --> 00:01:46,869 I should have a personalized experience so that I'm welcomed by the brand. 34 00:01:46,869 --> 00:01:51,249 So I'm gonna move that to In Progress and okay. 35 00:01:51,249 --> 00:01:54,855 So to personalize things, we need to capture our user's name. 36 00:01:54,855 --> 00:01:59,314 We're gonna need to use it a bit to make things seem personalized, right? 37 00:01:59,314 --> 00:02:03,476 So here, let me make this comment here for us. 38 00:02:03,476 --> 00:02:08,386 Why is that indenting? 39 00:02:08,386 --> 00:02:09,322 You know why it's indenting? 40 00:02:09,322 --> 00:02:09,980 Look at this. 41 00:02:11,050 --> 00:02:11,846 Look what I forgot. 42 00:02:11,846 --> 00:02:13,463 You see how that's indenting there? 43 00:02:13,463 --> 00:02:15,180 What's missing? 44 00:02:15,180 --> 00:02:16,463 I forgot this. 45 00:02:16,463 --> 00:02:18,035 There we go. 46 00:02:18,035 --> 00:02:23,333 [SOUND] All, right, so I'm going to make a comment. 47 00:02:23,333 --> 00:02:29,254 So we'll say, Gather the user's name and 48 00:02:29,254 --> 00:02:33,208 assign it to a new variable. 49 00:02:33,208 --> 00:02:34,905 Okay, you totally got this. 50 00:02:34,905 --> 00:02:37,949 Go ahead and pause me, and after you get it, unpause me, and 51 00:02:37,949 --> 00:02:39,339 I'll show you how I did it. 52 00:02:40,881 --> 00:02:43,504 Ready, so here's what I did. 53 00:02:43,504 --> 00:02:49,536 I came in here and I said, name = input("What is your name? 54 00:02:49,536 --> 00:02:53,766 And I left some spaces, because we know how that feels. 55 00:02:53,766 --> 00:02:56,334 So we can't really personalize anything cuz there's nothing here yet. 56 00:02:56,334 --> 00:02:58,904 So, let's flip back over to the tasks. 57 00:02:58,904 --> 00:03:00,146 Ooh, here's a good one. 58 00:03:00,146 --> 00:03:03,235 As a User I should be able to request a certain amount of tickets and be told 59 00:03:03,235 --> 00:03:06,443 the total costs so that I could determine if I want to purchase the tickets. 60 00:03:06,443 --> 00:03:10,185 We can totally use this personalization in the prompt. 61 00:03:10,185 --> 00:03:11,036 That sounds good. 62 00:03:11,036 --> 00:03:12,319 Let's do that. 63 00:03:15,025 --> 00:03:17,274 Okay, so let's see. 64 00:03:17,274 --> 00:03:18,739 We've got three steps here, right? 65 00:03:18,739 --> 00:03:24,087 So we've got Prompt the user by name and 66 00:03:24,087 --> 00:03:29,281 ask how many tickets they would like. 67 00:03:29,281 --> 00:03:32,272 Sounds good, so personalizing it. 68 00:03:32,272 --> 00:03:34,334 We'll say, hey, Bob. 69 00:03:34,334 --> 00:03:35,499 How many tickets would you like? 70 00:03:35,499 --> 00:03:38,573 And then we'll need to do some calculation. 71 00:03:38,573 --> 00:03:40,749 So we'll calculate the price. 72 00:03:40,749 --> 00:03:41,627 What is that? 73 00:03:41,627 --> 00:03:48,390 That would be the number of tickets that they want, 74 00:03:48,390 --> 00:03:52,964 right, multiplied by the price. 75 00:03:52,964 --> 00:03:56,768 And you should use that ticket price variable up there. 76 00:03:56,768 --> 00:03:59,881 And then we will assign that to a variable. 77 00:04:02,511 --> 00:04:04,043 And then finally, 78 00:04:04,043 --> 00:04:09,021 I think we just need enough to output the price to the screen for 79 00:04:09,021 --> 00:04:14,508 this story to be done, so we'll say Output the price to the screen. 80 00:04:14,508 --> 00:04:17,306 Okay, so there's three tasks there. 81 00:04:17,306 --> 00:04:18,959 I want you to take them nice and slow. 82 00:04:18,959 --> 00:04:20,104 You can totally do this. 83 00:04:20,104 --> 00:04:24,038 If you get stuck along the way, I invite you to hit up your teammates who are also 84 00:04:24,038 --> 00:04:26,075 working through this in the community. 85 00:04:26,075 --> 00:04:27,525 And you can also unpause me and 86 00:04:27,525 --> 00:04:30,197 I'll give you a warning before I start the other ones. 87 00:04:30,197 --> 00:04:31,939 Ready, you got this. 88 00:04:31,939 --> 00:04:33,811 Pause me. 89 00:04:33,811 --> 00:04:39,258 Okay so the first thing that I did was I got num_tickets 90 00:04:39,258 --> 00:04:44,233 = input("How many tickets would you like, and 91 00:04:44,233 --> 00:04:50,288 then I'm gonna put the place holder with their name in here. 92 00:04:50,288 --> 00:04:52,908 And then, a couple spaces. 93 00:04:52,908 --> 00:04:57,275 And let's go ahead an do format, and then we'll push the name in, okay? 94 00:04:57,275 --> 00:05:00,361 Close that paren off, awesome. 95 00:05:00,361 --> 00:05:02,714 Now to calculate the price, and this might had been tricky, 96 00:05:02,714 --> 00:05:04,111 this might have caught some of you. 97 00:05:04,111 --> 00:05:07,097 We first need to make sure that we have an integer. 98 00:05:07,097 --> 00:05:12,205 So what I did was I reassigned num_tickets, so 99 00:05:12,205 --> 00:05:17,326 I said num_tickets = int(num_tickets). 100 00:05:17,326 --> 00:05:23,238 So now we have an integer in num_tickets, is reassigned. 101 00:05:23,238 --> 00:05:25,524 Okay, and then I calculated the price. 102 00:05:25,524 --> 00:05:28,756 And that was amount_due. 103 00:05:28,756 --> 00:05:35,328 And that's equal to the num_tickets * TICKET_PRICE. 104 00:05:35,328 --> 00:05:37,050 Okay, how'd you do? 105 00:05:37,050 --> 00:05:38,973 Hope that coercion didn't trip you up. 106 00:05:38,973 --> 00:05:43,616 Okay, and finally I output the total again, using the format method on strings. 107 00:05:43,616 --> 00:05:46,275 And it doesn't matter that amount due is an integer, 108 00:05:46,275 --> 00:05:48,652 it automatically coerces it to a string for us. 109 00:05:48,652 --> 00:05:54,685 So, print("The total due is. 110 00:06:01,816 --> 00:06:05,319 So this is what mine looks like when it runs. 111 00:06:05,319 --> 00:06:06,616 Does yours work? 112 00:06:06,616 --> 00:06:11,325 Let's see, we'll say python masterticket. 113 00:06:14,333 --> 00:06:18,215 My name is Craig, and I would like to buy three tickets. 114 00:06:18,215 --> 00:06:21,593 Total due is 30 bucks, awesome! 115 00:06:21,593 --> 00:06:23,603 Is yours working, too? 116 00:06:23,603 --> 00:06:27,957 So let's flip over to Trello, and we've got both of these done. 117 00:06:27,957 --> 00:06:29,160 That's a personalized experience. 118 00:06:29,160 --> 00:06:30,477 We got to remember to keep doing that. 119 00:06:30,477 --> 00:06:32,327 They seemed really keen on that. 120 00:06:32,327 --> 00:06:35,747 And they are also able to request a certain amount of questions, and 121 00:06:35,747 --> 00:06:37,135 we got told the total cost. 122 00:06:37,135 --> 00:06:38,473 We are cruising along. 123 00:06:38,473 --> 00:06:41,800 Let's tackle the next few user stories right after this quick break.