Variables Loops and Lists

Remembering with Variables

Variables are like boxes we use to store numbers and words, so they are the memory of a program. We could have variables to track how much fruit we have

apples = 10
oranges = 6

Then use those names later to add all of our fruits together.

print(apples+oranges)
16

Repeating with Loops

Loops are a really important part of progams that let a program do something more than once without writing the same code over and over. For instance, if we wanted to print “Yeah Tina!” three times, you could write:

print("Yeah Tina!")
print("Yeah Tina!")
print("Yeah Tina!")

But, it would be much better to use a loop instead, which would look like this:

for i in range(3):
    print("Yeah Tina!")

Lists

List are a very important thing in programming, one of many data structures that hold data. A list is a lot like a list that you know about, like a grocery list:

Things To Buy
  - apples
  - oranges
  - bread 
  - milk

But in Python, a list can hold a lot more than just names of grocery items.

Now lets learn how to use these new programming ideas in our programs.