-
Introduction 4
-
Lecture1.1
-
Lecture1.2
-
Lecture1.3
-
Lecture1.4
-
-
Production Possibilities Frontier 4
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
Lecture2.4
-
-
Trade 3
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
-
Demand 4
-
Lecture4.1
-
Lecture4.2
-
Lecture4.3
-
Lecture4.4
-
-
Supply 2
-
Lecture5.1
-
Lecture5.2
-
-
Equilibrium 4
-
Lecture6.1
-
Lecture6.2
-
Lecture6.3
-
Lecture6.4
-
-
Curve Movements 4
-
Lecture7.1
-
Lecture7.2
-
Lecture7.3
-
Lecture7.4
-
-
Elasticity and Revenue 5
-
Lecture8.1
-
Lecture8.2
-
Lecture8.3
-
Lecture8.4
-
Lecture8.5
-
-
Taxes 7
-
Lecture9.1
-
Lecture9.2
-
Lecture9.3
-
Lecture9.4
-
Lecture9.5
-
Lecture9.6
-
Lecture9.7
-
-
Consumer and Producer Surplus 8
-
Lecture10.1
-
Lecture10.2
-
Lecture10.3
-
Lecture10.4
-
Lecture10.5
-
Lecture10.6
-
Lecture10.7
-
Lecture10.8
-
-
Imports and Exports 4
-
Lecture11.1
-
Lecture11.2
-
Lecture11.3
-
Lecture11.4
-
-
Tariffs 2
-
Lecture12.1
-
Lecture12.2
-
Loops
First, we need to learn some python. Take a look at the code below.
for x in range(0,11):
print(x)
The first line starts a loop. What a loop does is it runs a block of code multiple times with a different variable each time. Let’s walk through each word. “for” starts the loop out and “x” is what we name the variable we want for each loop. “in” comes after we choose our variable name, and “range(0,11)” gives us the numbers from 0 to 10. The way range works is you write range(a,b) and you get the numbers between a and b-1. So for this range we get 0,1,2…10. Finally, you put a colon after to start your loop.
Now for the next line, you’ll notice it is indented. Anything you want in your block of code that will be run during the for loop must be indented by pressing tab. Once you write a line of code that isn’t indented then the for loop is over. So the loop will run 11 times before any line after runs. If you run this code then you will notice that the numbers 0 to 10 get printed out.
for x in range(0,11):
print(x*2)
print("Done!")
The above code is another example of using a for loop. When you put this in you get the numbers 0,2,4,6…20 printed out. Then the word done is printed out after.
Now let’s talk about the production possibilities frontier. Jim has 10 hours to work each day and can make two things: hamburgers or salads. Jim puts x hours into hamburgers, and then puts 10-x hours into salads. For every hour of work he puts into hamburgers, Jim makes 2 hamburgers. For every hour of work he puts into salads, Jim makes 4 salads. Let’s use python to show all the different combinations of hamburgers and salads Jim can make splitting up his hours of work.
Challenge