Python for Absolute Beginners Transcripts
Chapter: Code that interacts with users
Lecture: Practice time!
0:00 It's time for some practice exercises. So again, the easiest way to get to the GitHub Repository just go to the course page and click right there.
0:09 We're going to go down to our practices and now we're in chapter five, interactive code. So let's see what I've put on deck for you here.
0:18 The idea is work on these, but don't let them drag you down. Don't get stuck. Don't stop going to the class and for some reason, you do get stuck there
0:26 we talked about how to get help at the beginning of the course. All of those things but eventually move on if you get stuck but here's the idea.
0:33 I'm going to cover a couple of core concepts how do you run Python code, not in the REPL but execute a Python source file
0:40 so we talked about that and it's up there if else statements, here's some examples for those also while loops, you're going to need both of those
0:48 in the exercises. Something we haven't spoken about but is really interesting and common in programming is actually working with the remainder.
0:57 Turns out this is more useful in programming than it is in, like, regular life so we all know about remainders
1:03 like if you do whole number divisions say like 19 divided by 5 well that's like, 3.8 but in whole number division it's three with four left over, right
1:15 so there's a way in programming in Python to say, give me the remainder of this division so 19 %, modulus, mod, 5 with the remainder which is four.
1:27 The reason we need this is, in the exercises I ask you to work with even numbers, and this is how you check if something is even, right there.
1:34 Now you have those as reference to work from what are the exercises? First one, here we go again, hello world. Idea is just to create helloworld.py
1:44 a file that prints out hello world like we did before but now just make sure that you can execute a Python file right, so there's some examples above
1:53 if you do this in PyCharm that's easy there's some notes here on how to do that. You're not using PyCharm there's also some notes above
1:59 on how to run it. Next, write a program that requests a number from a user and then print out whether or not it's even or odd.
2:08 So, that's simple, and then you can extend that program in the next exercise, here to continue to ask that question
2:17 as long as they provide a non-zero number. So if they provide 27, say odd if they provide 90, say even
2:23 but if they provide zero, say goodbye and stop the program exit the program nicely. Right, so that's the idea
2:31 and then pick one of these ideas over here and visualize it at http://www.Pythontutor.com. Alright, well that's the exercises for you
2:40 be sure to practice them, also if you'd like go ahead and go through the example we did in the videos remember the example that we did is up here
2:49 we go back into code, here Vector five, that's the M&M game without going exactly through this source code here
2:59 why don't you go and try to recreate this little M&M game or some variation on it for yourself using just the stuff that we saw back here
3:09 with some of these core concepts and what not. That's one more thing to throw in there for you to practice and hopefully you get good
3:15 at if statements, while loops and making code decide things.