Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lectures/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ You can install [QuantEcon.py](http://quantecon.org/quantecon-py) by
starting Jupyter and typing

```{code-block} ipython3
:class: no-execute

!conda install quantecon
```

Expand All @@ -373,6 +375,8 @@ into a cell.
Alternatively, you can type the following into a terminal

```{code-block} bash
:class: no-execute

conda install quantecon
```

Expand All @@ -381,6 +385,8 @@ More instructions can be found on the [library page](http://quantecon.org/quante
To upgrade to the latest version, which you should do regularly, use

```{code-block} bash
:class: no-execute

conda upgrade quantecon
```

Expand All @@ -389,6 +395,8 @@ Another library we will be using is [interpolation.py](https://github.com/EconFo
This can be installed by typing in Jupyter

```{code-block} ipython3
:class: no-execute

!conda install -c conda-forge interpolation
```

Expand Down Expand Up @@ -517,6 +525,8 @@ As the 1st task, try
For example, if you've installed the command line version, open up a terminal and enter.

```{code-block} bash
:class: no-execute

git clone https://github.com/QuantEcon/QuantEcon.py
```

Expand Down
2 changes: 2 additions & 0 deletions lectures/need_for_speed.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ Compiled languages avoid these overheads with explicit, static types.
For example, consider the following C code, which sums the integers from 1 to 10

```{code-block} c
:class: no-execute

#include <stdio.h>

int main(void) {
Expand Down
10 changes: 10 additions & 0 deletions lectures/python_advanced_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ All iterators can be placed to the right of the `in` keyword in `for` loop state
In fact this is how the `for` loop works: If we write

```{code-block} python3
:class: no-execute

for x in iterator:
<code block>
```
Expand All @@ -156,6 +158,8 @@ then the interpreter
So now you know how this magical looking syntax works

```{code-block} python3
:class: no-execute

f = open('somefile.txt', 'r')
for line in f:
# do something
Expand Down Expand Up @@ -527,6 +531,8 @@ We are now working in the module `__main__`, and hence the namespace for `__main
Next, we import a module called `amodule`

```{code-block} python3
:class: no-execute

import amodule
```

Expand Down Expand Up @@ -1661,6 +1667,8 @@ Write a function to recursively compute the $t$-th Fibonacci number for any $t$.
Complete the following code, and test it using [this csv file](https://raw.githubusercontent.com/QuantEcon/lecture-python-programming/master/source/_static/lecture_specific/python_advanced_features/test_table.csv), which we assume that you've put in your current working directory

```{code-block} python3
:class: no-execute

def column_iterator(target_file, column_number):
"""A generator function for CSV files.
When called with a file name target_file (string) and column number
Expand All @@ -1681,6 +1689,8 @@ for date in dates:
Suppose we have a text file `numbers.txt` containing the following lines

```{code-block} none
:class: no-execute

prices
3
8
Expand Down
4 changes: 4 additions & 0 deletions lectures/python_by_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ easily enough if you look around.
On this machine, it's located in

```{code-block} ipython
:class: no-execute

anaconda3/lib/python3.7/site-packages/numpy
```

Expand Down Expand Up @@ -334,6 +336,8 @@ This example helps to clarify how the `for` loop works: When we execute a
loop of the form

```{code-block} python3
:class: no-execute

for variable_name in sequence:
<code block>
```
Expand Down
8 changes: 8 additions & 0 deletions lectures/python_essentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ Note that if `newfile.txt` is not in the present working directory then this cal
In this case, you can shift the file to the pwd or specify the [full path](https://en.wikipedia.org/wiki/Path_%28computing%29) to the file

```{code-block} python3
:class: no-execute

f = open('insert_full_path_to_file/newfile.txt', 'r')
```

Expand Down Expand Up @@ -621,6 +623,8 @@ f?
```

```{code-block} ipython
:class: no-execute

Type: function
String Form:<function f at 0x2223320>
File: /home/john/temp/temp.py
Expand All @@ -633,6 +637,8 @@ f??
```

```{code-block} ipython
:class: no-execute

Type: function
String Form:<function f at 0x2223320>
File: /home/john/temp/temp.py
Expand Down Expand Up @@ -693,6 +699,8 @@ Here the function created by `lambda` is said to be *anonymous* because it was n
In a {ref}`previous lecture <python_by_example>`, you came across the statement

```{code-block} python3
:class: no-execute

plt.plot(x, 'b-', label="white noise")
```

Expand Down
4 changes: 4 additions & 0 deletions lectures/python_oop.md
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,8 @@ Implement $F_n$ as a class called `ECDF`, where
Your code should work as follows (modulo randomness)

```{code-block} python3
:class: no-execute

from random import uniform

samples = [uniform(0, 1) for i in range(10)]
Expand All @@ -785,6 +787,8 @@ F(0.5) # Evaluate ecdf at x = 0.5
```

```{code-block} python3
:class: no-execute

F.observations = [uniform(0, 1) for i in range(1000)]
F(0.5)
```
Expand Down