Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
python-uga
py-training-2017
Commits
d1bbbe7a
Commit
d1bbbe7a
authored
Nov 25, 2019
by
paugier
Browse files
Fix pres function (without unittest)
parent
b7a59175
Pipeline
#32463
passed with stage
in 51 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ipynb/pres030_functions.ipynb
View file @
d1bbbe7a
...
...
@@ -49,12 +49,10 @@
%% Cell type:code id: tags:
```
python
import
unittest
def
add
(
arg0
,
arg1
):
"""Print and return the sum of the two arguments (duck typing)."""
result
=
arg0
+
arg1
print
(
'result = '
,
result
)
return
result
...
...
@@ -88,23 +86,20 @@
Write a function that returns the sum of the first argument with twice the second argument.
%% Cell type:code id: tags:
```
python
import
unittest
def
add_second_twice
(
arg0
,
arg1
):
"""Return the sum of the first argument with twice the second one.
Arguments should be of type that support sum and product by
an integer (e.g. numerical, string, list, ...)
:param arg0: first argument
:param arg1: second argument
:return: arg0 + 2 * arg1
"""
pass
```
%% Cell type:markdown id: tags:
### Do it yourself: simple function definition
...
...
@@ -124,11 +119,11 @@
"""
result
=
arg0
+
2
*
arg1
print
(
f
'arg0 + 2*arg1 =
{
arg0
}
+ 2*
{
arg1
}
=
{
result
}
'
)
return
result
myfunc
(
4
,
6
)
add_second_twice
(
4
,
6
)
```
%%%% Output: execute_result
16
...
...
@@ -137,14 +132,10 @@
```
python
myfunc
(
'a'
,
'b'
)
```
%%%% Output: execute_result
'abb'
%% Cell type:markdown id: tags:
## Is the function correct ?
-
What does it means
**correct**
?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment