[Python-checkins] CVS: python/dist/src/Doc/tut tut.tex,1.135,1.136

Tim Peters tim_one@users.sourceforge.net
2001年5月21日 23:54:41 -0700


Update of /cvsroot/python/python/dist/src/Doc/tut
In directory usw-pr-cvs1:/tmp/cvs-serv30053/python/dist/src/Doc/tut
Modified Files:
	tut.tex 
Log Message:
Changed all the examples with ugly platform-dependent float output to use
numbers that display nicely after repr(). From much doctest experience
with the same trick, I believe people find examples with simple fractions
easier to understand too: they can usually check the results in their
head, and so feel confident about what they're seeing. Not even I get a
warm feeling from a result that looks like 70330.345024097141 ...
Index: tut.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/tut/tut.tex,v
retrieving revision 1.135
retrieving revision 1.136
diff -C2 -r1.135 -r1.136
*** tut.tex	2001年05月21日 16:55:39	1.135
--- tut.tex	2001年05月22日 06:54:14	1.136
***************
*** 427,432 ****
 
 \begin{verbatim}
! >>> 4 * 2.5 / 3.3
! 3.0303030303030303
 >>> 7.0 / 2
 3.5
--- 427,432 ----
 
 \begin{verbatim}
! >>> 3 * 3.75 / 1.5
! 7.5
 >>> 7.0 / 2
 3.5
***************
*** 470,474 ****
 
 \begin{verbatim}
! >>> a=1.5+0.5j
 >>> float(a)
 Traceback (most recent call last):
--- 470,474 ----
 
 \begin{verbatim}
! >>> a=3.0+4.0j
 >>> float(a)
 Traceback (most recent call last):
***************
*** 476,482 ****
 TypeError: can't convert complex to float; use e.g. abs(z)
 >>> a.real
! 1.5
! >>> abs(a)
! 1.5811388300841898
 \end{verbatim}
 
--- 476,485 ----
 TypeError: can't convert complex to float; use e.g. abs(z)
 >>> a.real
! 3.0
! >>> a.imag
! 4.0
! >>> abs(a) # sqrt(a.real**2 + a.imag**2)
! 5.0
! >>>
 \end{verbatim}
 
***************
*** 487,498 ****
 
 \begin{verbatim}
! >>> tax = 17.5 / 100
! >>> price = 3.50
 >>> price * tax
! 0.61249999999999993
 >>> price + _
! 4.1124999999999998
 >>> round(_, 2)
! 4.1100000000000003
 \end{verbatim}
 
--- 490,502 ----
 
 \begin{verbatim}
! >>> tax = 12.5 / 100
! >>> price = 100.50
 >>> price * tax
! 12.5625
 >>> price + _
! 113.0625
 >>> round(_, 2)
! 113.06
! >>>
 \end{verbatim}
 
***************
*** 2610,2623 ****
 
 \begin{verbatim}
! >>> x = 10 * 3.14
 >>> y = 200 * 200
 >>> s = 'The value of x is ' + `x` + ', and y is ' + `y` + '...'
 >>> print s
! The value of x is 31.400000000000002, and y is 40000...
 >>> # Reverse quotes work on other types besides numbers:
 ... p = [x, y]
 >>> ps = repr(p)
 >>> ps
! '[31.400000000000002, 40000]'
 >>> # Converting a string adds string quotes and backslashes:
 ... hello = 'hello, world\n'
--- 2614,2627 ----
 
 \begin{verbatim}
! >>> x = 10 * 3.25
 >>> y = 200 * 200
 >>> s = 'The value of x is ' + `x` + ', and y is ' + `y` + '...'
 >>> print s
! The value of x is 32.5, and y is 40000...
 >>> # Reverse quotes work on other types besides numbers:
 ... p = [x, y]
 >>> ps = repr(p)
 >>> ps
! '[32.5, 40000]'
 >>> # Converting a string adds string quotes and backslashes:
 ... hello = 'hello, world\n'
***************
*** 2627,2631 ****
 >>> # The argument of reverse quotes may be a tuple:
 ... `x, y, ('spam', 'eggs')`
! "(31.400000000000002, 40000, ('spam', 'eggs'))"
 \end{verbatim}
 
--- 2631,2635 ----
 >>> # The argument of reverse quotes may be a tuple:
 ... `x, y, ('spam', 'eggs')`
! "(32.5, 40000, ('spam', 'eggs'))"
 \end{verbatim}
 
***************
*** 3478,3482 ****
 ... self.i = imagpart
 ... 
! >>> x = Complex(3.0,-4.5)
 >>> x.r, x.i
 (3.0, -4.5)
--- 3482,3486 ----
 ... self.i = imagpart
 ... 
! >>> x = Complex(3.0, -4.5)
 >>> x.r, x.i
 (3.0, -4.5)

AltStyle によって変換されたページ (->オリジナル) /