Kaydet (Commit) 8b0b8409 authored tarafından Fred Drake's avatar Fred Drake

Update output to reflect additional precision produced by the repr() of

floating point numbers in an interactive example.


Added comment to help explain control flow in the example code showing
how to check if a number is prime.

This closes SF bugs 419434 and 424552.
üst 24e62191
...@@ -1166,6 +1166,7 @@ which searches for prime numbers: ...@@ -1166,6 +1166,7 @@ which searches for prime numbers:
... print n, 'equals', x, '*', n/x ... print n, 'equals', x, '*', n/x
... break ... break
... else: ... else:
... # loop fell through without finding a factor
... print n, 'is a prime number' ... print n, 'is a prime number'
... ...
2 is a prime number 2 is a prime number
...@@ -2609,10 +2610,10 @@ reverse quotes (\code{``}). Some examples: ...@@ -2609,10 +2610,10 @@ reverse quotes (\code{``}). Some examples:
\begin{verbatim} \begin{verbatim}
>>> x = 10 * 3.14 >>> x = 10 * 3.14
>>> y = 200*200 >>> y = 200 * 200
>>> s = 'The value of x is ' + `x` + ', and y is ' + `y` + '...' >>> s = 'The value of x is ' + `x` + ', and y is ' + `y` + '...'
>>> print s >>> print s
The value of x is 31.4, and y is 40000... The value of x is 31.400000000000002, and y is 40000...
>>> # Reverse quotes work on other types besides numbers: >>> # Reverse quotes work on other types besides numbers:
... p = [x, y] ... p = [x, y]
>>> ps = repr(p) >>> ps = repr(p)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment