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
f058d2dc
Kaydet (Commit)
f058d2dc
authored
Kas 23, 2009
tarafından
Mark Dickinson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #7369: Fibonacci series should start at 0 in tutorial example.
üst
e13dc3e6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
controlflow.rst
Doc/tutorial/controlflow.rst
+9
-9
No files found.
Doc/tutorial/controlflow.rst
Dosyayı görüntüle @
f058d2dc
...
...
@@ -194,13 +194,13 @@ boundary::
>>> def fib(n): # write Fibonacci series up to n
... """Print a Fibonacci series up to n."""
... a, b = 0, 1
... while
b
< n:
... print
b
,
... while
a
< n:
... print
a
,
... a, b = b, a+b
...
>>> # Now call the function we just defined:
... fib(2000)
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597
0
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597
.. index::
single: documentation strings
...
...
@@ -244,7 +244,7 @@ mechanism::
<function fib at 10042ed0>
>>> f = fib
>>> f(100)
1 1 2 3 5 8 13 21 34 55 89
0
1 1 2 3 5 8 13 21 34 55 89
Coming from other languages, you might object that ``fib`` is not a function but
a procedure since it doesn't return a value. In fact, even functions without a
...
...
@@ -264,14 +264,14 @@ Fibonacci series, instead of printing it::
... """Return a list containing the Fibonacci series up to n."""
... result = []
... a, b = 0, 1
... while
b
< n:
... result.append(
b
) # see below
... while
a
< n:
... result.append(
a
) # see below
... a, b = b, a+b
... return result
...
>>> f100 = fib2(100) # call it
>>> f100 # write the result
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
[
0,
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
This example, as usual, demonstrates some new Python features:
...
...
@@ -279,7 +279,7 @@ This example, as usual, demonstrates some new Python features:
:keyword:`return` without an expression argument returns ``None``. Falling off
the end of a function also returns ``None``.
* The statement ``result.append(
b
)`` calls a *method* of the list object
* The statement ``result.append(
a
)`` calls a *method* of the list object
``result``. A method is a function that 'belongs' to an object and is named
``obj.methodname``, where ``obj`` is some object (this may be an expression),
and ``methodname`` is the name of a method that is defined by the object's type.
...
...
@@ -288,7 +288,7 @@ This example, as usual, demonstrates some new Python features:
object types and methods, using *classes*, see :ref:`tut-classes`)
The method :meth:`append` shown in the example is defined for list objects; it
adds a new element at the end of the list. In this example it is equivalent to
``result = result + [
b
]``, but more efficient.
``result = result + [
a
]``, but more efficient.
.. _tut-defining:
...
...
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