Part 1, Welcome to python
Welcome to Python! Python is a really great programming language, thats easy to learn and fun to use. In order to write python code, you have two options. You can use what’s called interactive mode which is done by going to terminal and typing
You should see the following pop up:
Your other option is to use an editor like Sublime Text1, Atom2, or PyCharm3 to program
Either way, lets begin your first program.
The basis of programming is variables. Think back (or look ahead) to algebra, when you first learned about the magic ‘x’. x could be any number: 1, -10, 100, etc. Just like algebra, in Python when you want to make a variable all we have to say is:
The little hashtag, pound, number sign, etc. is what’s called a comment, we can put it after any complete line of code (but not in the middle of one) We can do all sorts of things to x, we can add to it
Now you may be wondering, okay all of this stuff worked, whatever I was using didn’t tell me anything went wrong. How do I know it worked though? Well let me tell you about something great
Lets make another variable, call it y!
Ready for some more great magic?! Just like algebra, we have more than just variables, we have functions! Just like Algebra, we can apply a function to a variable.
So this function will multiply the number we pass in by 10 and then print it out. Keep in mind, we actually have to tell python we want to use this function.
Something to note about python: spacing and indentation matters! A LOT!!!! Be sure that when you’re writing python code, you indent the next line after you type a colon
Okay, well that’s enough for now, next time we’ll go over different kinds of variables, built-in-functions, and functions with multiple parameters.