Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
8c26a34f
Kaydet (Commit)
8c26a34f
authored
Eki 14, 2017
tarafından
Raymond Hettinger
Kaydeden (comit)
GitHub
Eki 14, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-31757: Make Fibonacci examples consistent (#3991)
üst
073150db
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
18 deletions
+20
-18
introduction.rst
Doc/tutorial/introduction.rst
+10
-8
modules.rst
Doc/tutorial/modules.rst
+10
-10
No files found.
Doc/tutorial/introduction.rst
Dosyayı görüntüle @
8c26a34f
...
@@ -458,16 +458,18 @@ First Steps Towards Programming
...
@@ -458,16 +458,18 @@ First Steps Towards Programming
===============================
===============================
Of course, we can use Python for more complicated tasks than adding two and two
Of course, we can use Python for more complicated tasks than adding two and two
together. For instance, we can write an initial sub-sequence of the *Fibonacci*
together. For instance, we can write an initial sub-sequence of the
series as follows::
`Fibonacci series <https://en.wikipedia.org/wiki/Fibonacci_number>`_
as follows::
>>> # Fibonacci series:
>>> # Fibonacci series:
... # the sum of two elements defines the next
... # the sum of two elements defines the next
... a, b = 0, 1
... a, b = 0, 1
>>> while
b
< 10:
>>> while
a
< 10:
... print(
b
)
... print(
a
)
... a, b = b, a+b
... a, b = b, a+b
...
...
0
1
1
1
1
2
2
...
@@ -483,7 +485,7 @@ This example introduces several new features.
...
@@ -483,7 +485,7 @@ This example introduces several new features.
first before any of the assignments take place. The right-hand side expressions
first before any of the assignments take place. The right-hand side expressions
are evaluated from the left to the right.
are evaluated from the left to the right.
* The :keyword:`while` loop executes as long as the condition (here: ``
b
< 10``)
* The :keyword:`while` loop executes as long as the condition (here: ``
a
< 10``)
remains true. In Python, like in C, any non-zero integer value is true; zero is
remains true. In Python, like in C, any non-zero integer value is true; zero is
false. The condition may also be a string or list value, in fact any sequence;
false. The condition may also be a string or list value, in fact any sequence;
anything with a non-zero length is true, empty sequences are false. The test
anything with a non-zero length is true, empty sequences are false. The test
...
@@ -516,11 +518,11 @@ This example introduces several new features.
...
@@ -516,11 +518,11 @@ This example introduces several new features.
or end the output with a different string::
or end the output with a different string::
>>> a, b = 0, 1
>>> a, b = 0, 1
>>> while
b
< 1000:
>>> while
a
< 1000:
... print(
b
, end=',')
... print(
a
, end=',')
... a, b = b, a+b
... a, b = b, a+b
...
...
1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,
0,
1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,
.. rubric:: Footnotes
.. rubric:: Footnotes
...
...
Doc/tutorial/modules.rst
Dosyayı görüntüle @
8c26a34f
...
@@ -29,16 +29,16 @@ called :file:`fibo.py` in the current directory with the following contents::
...
@@ -29,16 +29,16 @@ called :file:`fibo.py` in the current directory with the following contents::
def
fib
(
n
):
#
write
Fibonacci
series
up
to
n
def
fib
(
n
):
#
write
Fibonacci
series
up
to
n
a
,
b
=
0
,
1
a
,
b
=
0
,
1
while
b
<
n
:
while
a
<
n
:
print
(
b
,
end
=
' '
)
print
(
a
,
end
=
' '
)
a
,
b
=
b
,
a
+
b
a
,
b
=
b
,
a
+
b
print
()
print
()
def
fib2
(
n
):
#
return
Fibonacci
series
up
to
n
def
fib2
(
n
):
#
return
Fibonacci
series
up
to
n
result
=
[]
result
=
[]
a
,
b
=
0
,
1
a
,
b
=
0
,
1
while
b
<
n
:
while
a
<
n
:
result
.
append
(
b
)
result
.
append
(
a
)
a
,
b
=
b
,
a
+
b
a
,
b
=
b
,
a
+
b
return
result
return
result
...
@@ -52,9 +52,9 @@ the current symbol table; it only enters the module name ``fibo`` there. Using
...
@@ -52,9 +52,9 @@ the current symbol table; it only enters the module name ``fibo`` there. Using
the
module
name
you
can
access
the
functions
::
the
module
name
you
can
access
the
functions
::
>>>
fibo
.
fib
(
1000
)
>>>
fibo
.
fib
(
1000
)
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
>>>
fibo
.
fib2
(
100
)
>>>
fibo
.
fib2
(
100
)
[
1
,
1
,
2
,
3
,
5
,
8
,
13
,
21
,
34
,
55
,
89
]
[
0
,
1
,
1
,
2
,
3
,
5
,
8
,
13
,
21
,
34
,
55
,
89
]
>>>
fibo
.
__name__
>>>
fibo
.
__name__
'fibo'
'fibo'
...
@@ -62,7 +62,7 @@ If you intend to use a function often you can assign it to a local name::
...
@@ -62,7 +62,7 @@ If you intend to use a function often you can assign it to a local name::
>>>
fib
=
fibo
.
fib
>>>
fib
=
fibo
.
fib
>>>
fib
(
500
)
>>>
fib
(
500
)
1
1
2
3
5
8
13
21
34
55
89
144
233
377
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
..
_tut
-
moremodules
:
..
_tut
-
moremodules
:
...
@@ -92,7 +92,7 @@ module directly into the importing module's symbol table. For example::
...
@@ -92,7 +92,7 @@ module directly into the importing module's symbol table. For example::
>>>
from
fibo
import
fib
,
fib2
>>>
from
fibo
import
fib
,
fib2
>>>
fib
(
500
)
>>>
fib
(
500
)
1
1
2
3
5
8
13
21
34
55
89
144
233
377
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
This
does
not
introduce
the
module
name
from
which
the
imports
are
taken
in
the
This
does
not
introduce
the
module
name
from
which
the
imports
are
taken
in
the
local
symbol
table
(
so
in
the
example
,
``
fibo
``
is
not
defined
).
local
symbol
table
(
so
in
the
example
,
``
fibo
``
is
not
defined
).
...
@@ -101,7 +101,7 @@ There is even a variant to import all names that a module defines::
...
@@ -101,7 +101,7 @@ There is even a variant to import all names that a module defines::
>>>
from
fibo
import
*
>>>
from
fibo
import
*
>>>
fib
(
500
)
>>>
fib
(
500
)
1
1
2
3
5
8
13
21
34
55
89
144
233
377
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
This
imports
all
names
except
those
beginning
with
an
underscore
(``
_
``).
This
imports
all
names
except
those
beginning
with
an
underscore
(``
_
``).
In
most
cases
Python
programmers
do
not
use
this
facility
since
it
introduces
In
most
cases
Python
programmers
do
not
use
this
facility
since
it
introduces
...
@@ -145,7 +145,7 @@ executed as the "main" file:
...
@@ -145,7 +145,7 @@ executed as the "main" file:
.. code-block:: shell-session
.. code-block:: shell-session
$ python fibo.py 50
$ python fibo.py 50
1 1 2 3 5 8 13 21 34
0
1 1 2 3 5 8 13 21 34
If the module is imported, the code is not run::
If the module is imported, the code is not run::
...
...
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