Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hub-courses
python_one_week_4_biologists_solutions
Commits
6b129c1d
Unverified
Commit
6b129c1d
authored
Jun 14, 2021
by
Bertrand NÉRON
Browse files
fix python 2 print
parent
48dbdd8d
Pipeline
#58651
passed with stages
in 15 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
source/Dive_into_Functions.rst
View file @
6b129c1d
...
...
@@ -28,11 +28,11 @@ help you by drawing diagram.
def func():
y = 5
print
locals()
print
(
locals()
)
>>> func()
{'y': 5}
>>> print
x
>>> print
(x)
4
.. container:: clearer
...
...
@@ -59,15 +59,15 @@ help you by drawing diagram.
def func():
y = 5
x = 8
print
locals()
print
(
locals()
)
x = x + 2
>>> y = func()
{'y': 5, 'x': 8}
>>>
>>> print
y
>>> print
(y)
None
>>> print
x
>>> print
(x)
4
.. container:: clearer
...
...
@@ -93,7 +93,7 @@ help you by drawing diagram.
def func(a):
y = x + 2
print
locals()
print
(
locals()
)
x = y
return y
...
...
@@ -134,7 +134,7 @@ help you by drawing diagram.
def func(a):
x = x + 2
print
locals()
print
(
locals()
)
return x
y = func(x)
...
...
@@ -171,9 +171,9 @@ help you by drawing diagram.
y = func(x)
>>> print
x
>>> print
(x)
4
>>> print
y == x
>>> print
(
y == x
)
False
.. container:: clearer
...
...
@@ -200,11 +200,11 @@ help you by drawing diagram.
>>> x = 4
>>> z = func()
>>>
>>> print
x
>>> print
(x)
4
>>> print
z
>>> print
(z)
4
>>> print
id(z) == id(x)
>>> print
(
id(z) == id(x)
)
True
.. container:: clearer
...
...
@@ -225,15 +225,15 @@ help you by drawing diagram.
x = 4
def func(x
=
5):
def func(x
=
5):
x = x + 2
return x
>>> y = func(x)
>>>
>>> print
x
>>> print
(x)
4
>>> print
y
>>> print
(y)
6
.. container:: clearer
...
...
@@ -259,7 +259,7 @@ help you by drawing diagram.
def func(a):
global x
def func2():
print
locals()
print
(
locals()
)
y = x + 4
return y
z = func2()
...
...
@@ -267,9 +267,9 @@ help you by drawing diagram.
y = func(x)
{}
>>> print
x
>>> print
(x)
4
>>> print
y
>>> print
(y)
8
.. container:: clearer
...
...
@@ -296,11 +296,11 @@ help you by drawing diagram.
y = func(x)
>>> print
x
>>> print
(x)
{'a': 4, 'b': 5}
>>> print y
{'a': 4, 'b': 5}
>>> print
x is y
>>> print
(
x is y
)
True
.. container:: clearer
...
...
@@ -326,9 +326,9 @@ help you by drawing diagram.
y = func(x)
>>> print
x
>>> print
(x)
{'a': 4, 'b': 5}
>>> print
y
>>> print
(y)
None
.. container:: clearer
...
...
@@ -398,7 +398,7 @@ help you by drawing diagram.
y = func(x)
print
x
print
(x)
{'a': 4, 'b': 6}
| in this code *func2* is executed
...
...
@@ -433,7 +433,7 @@ help you by drawing diagram.
y = func(x)
print
x
print
(x)
{'a': 4, 'b': 5}
| in this code *x* a variable x is defined locally in *func2* and hide the global variable x
...
...
@@ -444,7 +444,7 @@ help you by drawing diagram.
.. image :: _static/figs/spacer.png
Exercise
--------
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment