Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Programming course
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
courses
Programming course
Commits
87f1c3b4
Commit
87f1c3b4
authored
11 years ago
by
Vermaat
Browse files
Options
Downloads
Patches
Plain Diff
One more exercise
parent
8422a0eb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fibonacci.py
+0
-10
0 additions, 10 deletions
fibonacci.py
python.ipynb
+36
-20
36 additions, 20 deletions
python.ipynb
with
36 additions
and
30 deletions
fibonacci.py
deleted
100644 → 0
+
0
−
10
View file @
8422a0eb
def
fib
(
n
):
if
n
==
0
:
return
0
if
n
==
1
:
return
1
return
fib
(
n
-
1
)
+
fib
(
n
-
2
)
if
__name__
==
'
__main__
'
:
for
n
in
range
(
5
,
10
):
print
'
fib({0}) = {1}
'
.
format
(
n
,
fib
(
n
))
This diff is collapsed.
Click to expand it.
python.ipynb
+
36
−
20
View file @
87f1c3b4
...
...
@@ -784,7 +784,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
"type('
an example string
')"
"type('
I am a homo sapiens
')"
],
"language": "python",
"metadata": {},
...
...
@@ -792,13 +792,13 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number":
2
1,
"prompt_number":
1
1,
"text": [
"str"
]
}
],
"prompt_number":
2
1
"prompt_number":
1
1
},
{
"cell_type": "markdown",
...
...
@@ -818,7 +818,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
"'
abc
' * 5 + '
def
'"
"'
beer
' * 5 + '
whiskey
'"
],
"language": "python",
"metadata": {},
...
...
@@ -826,13 +826,13 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number":
2
2,
"prompt_number":
1
2,
"text": [
"'
abcabcabcabcabcdef
'"
"'
beerbeerbeerbeerbeerwhiskey
'"
]
}
],
"prompt_number":
2
2
"prompt_number":
1
2
},
{
"cell_type": "markdown",
...
...
@@ -845,7 +845,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
"a = '
abc
'\n",
"a = '
spezi
'\n",
"type(a)"
],
"language": "python",
...
...
@@ -854,13 +854,13 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number":
2
3,
"prompt_number":
1
3,
"text": [
"str"
]
}
],
"prompt_number":
2
3
"prompt_number":
1
3
},
{
"cell_type": "markdown",
...
...
@@ -873,7 +873,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
"'
abc
' + 34"
"'
beer
' + 34"
],
"language": "python",
"metadata": {},
...
...
@@ -884,12 +884,12 @@
"output_type": "pyerr",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-
2
4-
43a6c1044bb0
>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;34m'
abc
'\u001b[0m \u001b[1;33m+\u001b[0m \u001b[1;36m34\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;32m<ipython-input-
1
4-
ec918fbfdf41
>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;34m'
beer
'\u001b[0m \u001b[1;33m+\u001b[0m \u001b[1;36m34\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mTypeError\u001b[0m: cannot concatenate 'str' and 'int' objects"
]
}
],
"prompt_number":
2
4
"prompt_number":
1
4
},
{
"cell_type": "markdown",
...
...
@@ -1368,7 +1368,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
"len('a
bcdefghijkl
')"
"len('a
ttacgataggcatccgt
')"
],
"language": "python",
"metadata": {},
...
...
@@ -1376,13 +1376,13 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number":
39
,
"prompt_number":
15
,
"text": [
"1
2
"
"1
8
"
]
}
],
"prompt_number":
39
"prompt_number":
15
},
{
"cell_type": "code",
...
...
@@ -1408,7 +1408,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
"('a
bc
', 22, True, 'a
bc
').count('a
bc
')"
"('a
tg
', 22, True, 'a
tg
').count('a
tg
')"
],
"language": "python",
"metadata": {},
...
...
@@ -1416,13 +1416,13 @@
{
"metadata": {},
"output_type": "pyout",
"prompt_number":
4
1,
"prompt_number": 1
6
,
"text": [
"2"
]
}
],
"prompt_number":
4
1
"prompt_number": 1
6
},
{
"cell_type": "markdown",
...
...
@@ -3530,6 +3530,22 @@
" b = a"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"$\\S$ Exercise: Running code from a file\n",
"===\n",
"\n",
"* Save your k-mer counting code to a file `kmer_counting.py`.\n",
"* Include some code using it on an example string and printing the results.\n",
"* Run the code from the command line."
]
},
{
"cell_type": "markdown",
"metadata": {
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment