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:

  x = 5 #Your first python variable!

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

  x = x + 5 #adding
  x = x - 3 #subtracting
  x = x * 6 #multiplaction
  x = x / 4 #dividing

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

  print(x) # Lets see what x is!

Lets make another variable, call it y!

  y = 4 #Your second python variable!
  print(x+y) #We can add, subtract, divide, multiply, etc. 
  z = y / x #We can make a new variable called z based on x and 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.

  def f(x):
    w = x * 10

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.

  f(10) #call the method with some number

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

  def f(x): #THIS IS NO GOOD!!!
  w = x * 10


  def f(x): #This works fine!
    w = x * 10

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.