In [ ]:
# WELCOME TO THE WORLD OF PROGRAMMING
# Fear not... it's not actually as scary as it sounds
# A lot of it starts to make sense once you know the basic rules of the road

In [ ]:
# And Welcome to New Orleans. Laissez les bon temps roulez!

In [ ]:
# Let's start rolling by doing a little...math.

In [ ]:
# In programming, an INTEGER is a whole number. 
# If a number has a decimal point, it's called a FLOAT instead.

# So let's play around with some integers. 
# You can do all sorts of math on integers, just like you'd do with a calculator or in Excel.

In [ ]:


In [ ]:


In [ ]:
# In the command line Python interpreter or here in Jupyter Notebooks, these results will always show up. 
# But if you run an entire Python (.py) program, however short, they won't. 
# To get results to actually appear, you need to "print" them to the screen.

In [ ]:


In [ ]:
# So it's good practice to get into the habit of "printing" things when you want to see the results

In [ ]:


In [ ]:
# Order of operations works the same as real-world math you learned back in grade school

In [ ]:


In [ ]:
# ...is different than:

In [ ]:


In [ ]:
# VARIABLES

# Instead of always using actual values, we can create a VARIABLE to hold it
# It's kind of like a nickname, but much more than that.
# It stores the value and let's us do things with it.

In [ ]:


In [ ]:
# Let's print to see what we get

In [ ]:


In [ ]:
# Once you have a variable, you can run math on it by using its name like you would the number
# Multiplication

In [ ]:


In [ ]:


In [ ]:


In [ ]:
# You can get as complex as you want with these...

In [ ]:


In [ ]:
# You can work with powers by using two (*) together

In [ ]:


In [ ]:


In [ ]:
# You can also create more than one variable, and then do math on them

In [ ]:


In [ ]:
# You can idenifty what TYPE your variable is like this

In [ ]:


In [ ]:
# Are there other types? The answer - indeed!

In [ ]:
# One that we won't get into right now, but is useful to know about, is called a Boolean.
# It's basically a True/False choice. 
# Note: Because the equal sign (=) is used for variables, to say something actually EQUALS the value of something else,
# you need to use a double equal sign (==). Like this:

In [ ]:


In [ ]:


In [ ]:
# Now let's assign this to a variable that will store the result

In [ ]:


In [ ]:


In [ ]:
# Now, let's look at another type - one of the most popular out there -- TEXT 
# In programming, TEXT is referred to as a STRING

In [ ]:
# At its most basic, a string can be displayed like this... note the quotation marks (" ")
# Python actually doesn't care if you use single quotes or double quotes. But best to be consistent.

In [ ]:


In [ ]:


In [ ]:
# Let's create a variable assigned to a string instead.

# In Python, you don't have to declare a variable before you assign a value to it. 
# Just give it a name and assign it a value using the = sign.

In [ ]:


In [ ]:


In [ ]:


In [ ]:
#Once the variable is assigned, you can do all kinds of things with your string
#You can add other text to combine with it:

In [ ]:


In [ ]:
# You can also "multiply" your string. 
# Let's see what that means...

In [ ]:


In [ ]:
# .upper() is one of dozens of string methods, in many ways similar to the functions you might be familiar with in Excel. 

# Can you guess what it does? Yep!

In [ ]:


In [ ]:
# You might notice that the .upper() method doesn't PERMANENTLY change the "variable" variable. 
# We'll get to that in a minute, but watch what happens when we do this:

In [ ]:


In [ ]:
# Let's lowercase the string, too

In [ ]:


In [ ]:
#These work without variables at all, too, of course

In [ ]:


In [ ]:
#SLICING AND DICING STRINGS

In [ ]:
# You can use the brackets to 'slice' out characters from a string based on their position. 

# Notice in Python, that we start counting at zero. So variable[0] returns the "n" in "nicar". 
# The value after the colon is the position that we stop before. So variable[0:2] returns all the characters from 
# position 0 until before position 2.

In [ ]:


In [ ]:
#Using a variable of course works the same way

In [ ]:


In [ ]:
# Let's print the first four characters

In [ ]:


In [ ]:
# Let's print everything after the second character

In [ ]:


In [ ]:
# Remember when the .upper() method didn't change the variable? 
# A string is IMMUTABLE. 
# You can't change it in place, so if you want to change it, you have to create a NEW VARIABLE 
# and assign the new value to it.

In [ ]:


In [ ]:
#Another exmample - you can use replace() to do swap out part of the string for something new instead

In [ ]:


In [ ]:
#But look what happens when we call mystring...

In [ ]:


In [ ]:
# See what I mean? It doesn't "stick" unless you create a new variable

In [ ]:


In [ ]:


In [ ]:
#You can also use a function called split() to SPLIT a string based on a certain character

#Think about how this could be used for divded up names separated by commas:

In [ ]:


In [ ]:
# Let's try to split the string on the comma...

In [ ]:


In [ ]:


In [ ]:
# Let's create a variable to hold the results of this string

In [ ]:


In [ ]:


In [ ]:
# This type looks a little different, no?
# Let's get the type

In [ ]:


In [ ]:
# A list? Hmm. That's a new one.
# Because it's a LIST, we can get a specfic item by its index

In [ ]:


In [ ]:
#Wait, what IS a "list"???  
#Ask, and ye shall have an answer in the next session...

In [ ]:
# Continue to Part 2 ----->