# Storing Programs for Re-use

* Using ipython is great for learning because of the instant feedback, but at some point you will want to save your code to use for another day. To do so, we use our text editor to write code in a file that ends with the extension '.py'.
* All python scripts and test files used in the course can be downloaded <https://ki-data.mit.edu/bcc/teaching/IntroToPython.tgz>
* Login and password will be provided during class

### Examples

* Example 1

```
Open a text editor
type: print("I can program in Python!\n")
Save the file as expert.py

1) in Unix, type python expert.py
python expert.py 
I can program in Python!

2) in ipython type run expert.py
In [1]: run expert.py
I can program in Python!

3) include the following in the first line of your script and type ./expert.py in unix
#!/usr/bin/env python

4) in Canopy
Open expert.py
run expert.py

```

* Example 2

```
In text editor, let's type our palindrome code from example1 of "Control flow and loops" section.
Name the file palindrome.py. The script should look like the following:

manyseqs=['ACTGATG','ACTGGTCA','ATGATG','TCGAAGCT','GCAGGCG','GATCCTAG','CATGTCGT','CTCTATCTC']
for seq in manyseqs:
        if (seq==seq[::-1]):
                print("%s" %seq)

1) in Unix: python palindrome.py
python palindrome.py 
ACTGGTCA
TCGAAGCT
GATCCTAG
CTCTATCTC

2) in ipython:run palindrome.py
In [1]: run palindrome.py
ACTGGTCA
TCGAAGCT
GATCCTAG
CTCTATCTC

3) include the following in the first line of your script and type palindrome.py in unix
#!/usr/bin/env python
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://igb.mit.edu/mini-courses/python/introduction-to-python-for-biologists/storing-programs-for-re-use.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
