###### tags: `Lesson Notes` `Python` `ACC`
# More Intro to Python
Ok so we got strings down, but there has to be more to python that that right? But of course there is. So lets get to printing some other things
## Conditional Statements
So remember in JS you could do a if statement? Well python has that too. It's not all that different either. I'm just going to show you python code from here on though, you can always look at earlier notes for the JS stuff.
So there are 3 keywords to know for conditional statements:
* if = if the following is true do the instructions that follow
* elif = if the 1st statement was false please check to see if this is true, if it is follow my instructions
* else = No statements above me were true so please just do the instructions that follow
Lets see how this would look
```
state = "gas"
if state == "liquid":
print("This element is in it's liquid state")
elif state == "gas":
print("This element is in it's gas state")
else:
print("This element seems to be in it's solid state")
```
So looking at this it looks like the elif instructions should print as state is currently set to gas
Not too hard to understand right...relatively speaking that is.
## Loops
Ah the good old loops. How we love to hate them. All joking asside loops are important expecially as you all saw when working with API's. How else can you get a whole lot of data to show on the screen with out typing the same code over and over again.
Oh and I lied. I am going to bring up JS again. Remember how in JS with a for loop you had to have 3 things in the ()?
1. Starting value (typically i = 0;)
2. When to stop the loop (i < res.length;)
3. How much to change i each iteration (i++)
We got the same thing here and same order just not quite the same, so here is some code I will have JS first then the python version both saying the same thing:
```
JS version
for (i = 0; i < 5; i++) {
Instructions go here
}
Python version
for i in range(0, 5, 1):
Instructions go here
```
So not too different but for this one I thought seeing the JS version might help a little more. So here are a few examples of for loops and after the # I will put the output as well as why
```
for i in range(0, 5, 1):
print(i)
# Output: 0, 1, 2, 3, 4
So we said to start at 0, go until i is less than 5 and increase by 1 each iteration through
```
```
for i in range(10, 0, -5):
print(i)
# Output: 10, 5
Here we said start at 10, stop as long as i is greater than 0, and decrease by 5 each iteration
```
Here is a good diagram of a loop process

So as long as the condition is true (i is less than 5 for example) keep going once that condition is no longer true you exit the loop.
Want a good way to see the code in action? Check out this link:
[Python Tutor](http://www.pythontutor.com/visualize.html#mode=edit)