File tree Expand file tree Collapse file tree 3 files changed +36
-4
lines changed
Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Original file line number Diff line number Diff line change 3333\title {Think Python}
3434\author {Allen B. Downey}
3535\newcommand {\thetitle }{Think Python: How to Think Like a Computer Scientist}
36- \newcommand {\theversion }{2nd Edition, Version 2.2.14 }
36+ \newcommand {\theversion }{2nd Edition, Version 2.2.15 }
3737\newcommand {\thedate }{}
3838
3939% these styles get translated in CSS for the HTML version
@@ -8291,6 +8291,8 @@ \section{Debugging}
82918291
82928292In this example you could also use the built-in function {\tt sorted},
82938293which returns a new, sorted list and leaves the original alone.
8294+ \index {sorted!function}
8295+ \index {function!sorted}
82948296
82958297\begin {verbatim }
82968298>>> t2 = sorted(t)
@@ -8857,8 +8859,8 @@ \section{Looping and dictionaries}
88578859%
88588860Again, the keys are in no particular order. To traverse the keys
88598861in sorted order, you can use the built-in function {\tt sorted}:
8860- \index {keys method }
8861- \index {method!keys }
8862+ \index {sorted!function }
8863+ \index {function!sorted }
88628864
88638865\begin {verbatim }
88648866>>> for key in sorted(h):
@@ -10791,7 +10793,7 @@ \section{Dictionary subtraction}
1079110793diff = subtract(hist, words)
1079210794
1079310795print("Words in the book that aren't in the word list:")
10794- for word in diff.keys() :
10796+ for word in diff:
1079510797 print(word, end=' ')
1079610798\end {verbatim }
1079710799%
Original file line number Diff line number Diff line change @@ -35,6 +35,13 @@ def __str__(self):
3535 return '%s of %s' % (Card .rank_names [self .rank ],
3636 Card .suit_names [self .suit ])
3737
38+ def __eq__ (self , other ):
39+ """Checks whether self and other have the same rank and suit.
40+
41+ returns: boolean
42+ """
43+ return self .suit == other .suit and self .rank == other .rank
44+
3845 def __lt__ (self , other ):
3946 """Compares this card to other, first by suit, then rank.
4047
Original file line number Diff line number Diff line change 1+ """This file contains code for use with "Think Stats",
2+ by Allen B. Downey, available from greenteapress.com
3+
4+ Copyright 2014 Allen B. Downey
5+ License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html
6+ """
7+
8+ from __future__ import print_function , division
9+
10+ import unittest
11+ from Card import Card , Deck
12+
13+
14+ class Test (unittest .TestCase ):
15+
16+ def testDeckRemove (self ):
17+ deck = Deck ()
18+ card23 = Card (2 , 3 )
19+ deck .remove_card (card23 )
20+
21+
22+ if __name__ == "__main__" :
23+ unittest .main ()
You can’t perform that action at this time.
0 commit comments