Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
Python programming
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gerald W. Höfner
Python programming
Commits
69751311
Commit
69751311
authored
2 years ago
by
Franziska Niemeyer
Browse files
Options
Downloads
Patches
Plain Diff
Upload solutions for gap_exercise2_functions
parent
ab07bccb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Exercises/solutions/gap_exercise2_functions.ipynb
+166
-0
166 additions, 0 deletions
Exercises/solutions/gap_exercise2_functions.ipynb
with
166 additions
and
0 deletions
Exercises/solutions/gap_exercise2_functions.ipynb
0 → 100644
+
166
−
0
View file @
69751311
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "gap_exercise2_functions.ipynb",
"provenance": [],
"collapsed_sections": []
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"source": [
"# Python course - Exercises Gap text"
],
"metadata": {
"id": "kH0p2uT-sQ6y",
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "markdown",
"source": [
"Correct the Code"
],
"metadata": {
"id": "uW9SoYEyrlRL",
"pycharm": {
"name": "#%% md\n"
}
}
},
{
"cell_type": "code",
"source": [
"# How are functions defined?\n",
"def my_function(b):\n",
" print(b+10)\n",
"\n",
"a=5\n",
"my_function(a)"
],
"metadata": {
"id": "uoscfCSCK980",
"pycharm": {
"name": "#%%\n"
},
"outputId": "8fcbf234-1326-4646-dd6e-22fd75234693",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"15\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# What is missing?\n",
"def concat_sequences( seq1, seq2, seq3 ):\n",
" print(seq1 + seq2 + seq3)\n",
"\n",
"concat_sequences('ACGTC', 'GTCAA', 'TTACC')"
],
"metadata": {
"id": "VI2uTjtJMZ-L",
"pycharm": {
"name": "#%%\n"
},
"outputId": "0325b131-f435-4260-df26-4d917944680d",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"ACGTCGTCAATTACC\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# correct the code such that the function delivers b+10\n",
"def my_function(b):\n",
" return (b+10)\n",
"\n",
"result = my_function(5)\n",
"print(result)"
],
"metadata": {
"id": "GN89HlxMJRAQ",
"pycharm": {
"name": "#%%\n"
},
"outputId": "01ad604f-0877-457e-fabc-2cb8b922fc2a",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 4,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"15\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"# undefined number of arguments: what is needed?\n",
"def concat_sequences( seq ):\n",
" print(seq[0] + seq[1] + seq[2])\n",
"\n",
"concat_sequences(['ACGTC', 'GTCAA', 'TAGCTGC'])"
],
"metadata": {
"id": "UOsFUQSHKGXH",
"pycharm": {
"name": "#%%\n"
},
"outputId": "1fd92f39-73a6-4777-cddb-b7cf6c9108ad",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 7,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"ACGTCGTCAATAGCTGC\n"
]
}
]
}
]
}
\ No newline at end of file
%% Cell type:markdown id: tags:
# Python course - Exercises Gap text
%% Cell type:markdown id: tags:
Correct the Code
%% Cell type:code id: tags:
```
# How are functions defined?
def my_function(b):
print(b+10)
a=5
my_function(a)
```
%% Output
15
%% Cell type:code id: tags:
```
# What is missing?
def concat_sequences( seq1, seq2, seq3 ):
print(seq1 + seq2 + seq3)
concat_sequences('ACGTC', 'GTCAA', 'TTACC')
```
%% Output
ACGTCGTCAATTACC
%% Cell type:code id: tags:
```
# correct the code such that the function delivers b+10
def my_function(b):
return (b+10)
result = my_function(5)
print(result)
```
%% Output
15
%% Cell type:code id: tags:
```
# undefined number of arguments: what is needed?
def concat_sequences( seq ):
print(seq[0] + seq[1] + seq[2])
concat_sequences(['ACGTC', 'GTCAA', 'TAGCTGC'])
```
%% Output
ACGTCGTCAATAGCTGC
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