GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing raw.githubusercontent.com — raw.githubusercontent.com {
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# An introduction to solving biological problems with Python\n",
"\n",
"- Our course webpage: http://pycam.github.io\n",
"- Python website: https://www.python.org/ \n",
"- [Python 3 Standard Library](https://docs.python.org/3/library/index.html])"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Learning objectives\n",
"\n",
"- **Recall** what we've learned so far on variables, common data types and collections\n",
"- **Propose and create** solutions using these concepts in an exercise\n",
"- **Use** conditions to execute specific code block\n",
"- **Employ** loops to repeat code block\n",
"- **Practice** reading and writing files with Python\n",
"- **Solve** more complex exercises"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Course schedule - day two\n",
"\n",
"- 09:30-09:45: [0h15] **Introduction**\n",
"- 09:45-10:45: [1h00] **Session 2.1** - Conditional execution\n",
"- 10:45-11:00: *break*\n",
"- 11:00-12:30: [1h30] **Session 2.2** - Loops\n",
"- 12:30-13:30: *lunch break*\n",
"- 13:30-15:00: [1h30] **Session 2.3** - Files\n",
"- 15:00-15:15: *break*\n",
"- 15:15-16:15: [1h00] **Session 2.4** - Delimited files\n",
"- 16:15-16:30: *break*\n",
"- 16:30-17:00: [0h30] **Wrap-up**"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## What we've learned so far\n",
"\n",
"- Simple data types, Collections\n",
"- Functions used so far..."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Simple data types"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Integer: 1\n",
"Float 3.14\n",
"True\n"
]
}
],
"source": [
"## Integer\n",
"i = 1\n",
"print('Integer:', i)\n",
"## Float\n",
"x = 3.14\n",
"print('Float', x)\n",
"## Boolean\n",
"print(True)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ATGTCGTCTACAACACTspam's\n",
"ATGTCGTCTACAACACT spam's\n"
]
}
],
"source": [
"## String\n",
"s0 = '' # empty string\n",
"s1 = 'ATGTCGTCTACAACACT' # single quotes\n",
"s2 = \"spam's\" # double quotes\n",
"print(s1 + s2) # concatenate\n",
"print(s1, s2) # print"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Collections"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"A tuple: (2, 3, 4, 5)\n",
"First element of tuple: 2\n"
]
}
],
"source": [
"## Tuple - immutable\n",
"my_tuple = (2, 3, 4, 5)\n",
"print('A tuple:', my_tuple)\n",
"print('First element of tuple:', my_tuple[0])"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"A list: [2, 3, 4, 5]\n",
"First element of list: 2\n",
"Appended list: [2, 3, 4, 5, 12]\n",
"Modified list: [45, 3, 4, 5, 12]\n"
]
}
],
"source": [
"## List\n",
"my_list = [2, 3, 4, 5]\n",
"print('A list:', my_list)\n",
"print('First element of list:', my_list[0])\n",
"my_list.append(12)\n",
"print('Appended list:', my_list)\n",
"my_list[0] = 45\n",
"print('Modified list:', my_list)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Here is a string: ATGTCATTT\n",
"First character: A\n",
"Slice text[1:3]: TG\n",
"Number of characters in text 9\n"
]
}
],
"source": [
"## String - immutable, tuple of characters\n",
"text = \"ATGTCATTT\"\n",
"print('Here is a string:', text)\n",
"print('First character:', text[0])\n",
"print('Slice text[1:3]:', text[1:3])\n",
"print('Number of characters in text', len(text))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"A set: {1, 2, 4, 5, 6}\n"
]
}
],
"source": [
"## Set - unique unordered elements\n",
"my_set = set([1,2,2,2,2,4,5,6,6,6])\n",
"print('A set:', my_set)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"A dictionary: {'A': 'Adenine', 'C': 'Cytosine', 'G': 'Guanine', 'T': 'Thymine'}\n",
"Value associated to key C: Cytosine\n"
]
}
],
"source": [
"## Dictionary\n",
"my_dictionary = {\"A\": \"Adenine\", \n",
" \"C\": \"Cytosine\", \n",
" \"G\": \"Guanine\", \n",
" \"T\": \"Thymine\"}\n",
"print('A dictionary:', my_dictionary)\n",
"print('Value associated to key C:', my_dictionary['C'])"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Functions used so far..."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"There are 5 elements in the list ['A', 'C', 'A', 'T', 'G']\n",
"There are 2 letter A in the list ['A', 'C', 'A', 'T', 'G']\n",
"['ATG', 'TCA', 'CCG', 'GGC']\n"
]
}
],
"source": [
"my_list = ['A', 'C', 'A', 'T', 'G']\n",
"print('There are', len(my_list), 'elements in the list', my_list)\n",
"print('There are', my_list.count('A'), 'letter A in the list', my_list)\n",
"print(\"ATG TCA CCG GGC\".split())"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Next session\n",
"\n",
"Go to our next notebook: [python_basic_2_1](python_basic_2_1.ipynb)"
]
}
],
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
|
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |