Python Jumpstart by Building 10 Apps Transcripts
Chapter: App 1: Hello (you Pythonic) world
Lecture: Building Hello world, part 2
Login or purchase this course to watch this video and the rest of the course contents.
0:00 So back in PyCharm we need to grab hold of that value that is returned from input.
0:06 Let's be really explicit and call this user_text or something like this... ok. So in Python, when you have complex words
0:15 or variables and functions made up of multiple words, if you will, you typically separate them with underscores.
0:22 Other programming languages might write "userText" like this, where they use camel-casing, in Python it's all about the underscore.
0:30 So, we are going to call it this, so that gives us the user text and we could actually just print this out just to see what they entered,
0:37 so let's run this really quick say "I entered this", if I hit enter it just says "I entered this", excellent.
0:44 So we have got that value and print it back out. That's not exactly what we want to do though.
0:49 We want to actually store some kind of saying that we want to say and I believe it was "Nice to meet you", whatever they entered for their name.
0:57 So we'll say greeting = "Nice to meet you " and we want to sort of somehow incorporate this string here so in Python, they make it really easy
1:11 to combine strings just using the "+" sign. So we'll say, nice to meet you "+" user text and we can just print out that greeting,
1:21 give a little space so it's easier to read, so let's just run that, and see what we get. So down here, we can enter our name which will be Michael,
1:28 hit enter, and it says "Nice to meet you Michael". Perfect!!. So now, we've completed our first app, you can see we've worked with the print function,
1:37 we're calling it with parenthesis, passing a string literal, it's what you call it when you create them just in place like this,
1:43 passing these string literals as arguments, sometimes were not, calling the input function, again passing strings, catching the response,
1:52 the input into a variable called user text, we are concatenating to another string, a literal string plus a variable,
1:58 storing the greeting and we are printing it out. All right, pretty simple this application but it really gets us off to a good start to start building
2:06 more interesting complex applications that build on things like file i/o and web services and all sorts of cool stuff like that.