Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> ============= RESTART: D:\CSI33F19\Python3\Chapter2\Rational.py ============= >>> x= Rational(3, 4) >>> x <__main__.Rational object at 0x000001B9D693CE48> >>> print(x) 3/4 >>> y = Rational(1,2) >>> print(y) 1/2 >>> z = x*y >>> print(z) 3/8 >>> 24%5 4 >>> 4+8 12 >>> 3.4 +7.7 SyntaxError: unexpected indent >>> 3.4 + 7.7 11.1 >>> x +y Traceback (most recent call last): File "", line 1, in x +y TypeError: unsupported operand type(s) for +: 'Rational' and 'Rational' >>> ============= RESTART: D:\CSI33F19\Python3\Chapter2\Rational.py ============= >>> x Traceback (most recent call last): File "", line 1, in x NameError: name 'x' is not defined >>> x =Rational(3, 4) >>> y = Rational(1,2) >>> t =x +y >>> print(t) 10/8 >>> =========== RESTART: D:\CSI33F19\Python3\Chapter2\test_Rational.py =========== ... ---------------------------------------------------------------------- Ran 3 tests in 0.014s OK >>> =========== RESTART: D:\CSI33F19\Python3\Chapter2\test_Rational.py =========== ..F ====================================================================== FAIL: testMul (__main__.RationalTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\CSI33F19\Python3\Chapter2\test_Rational.py", line 27, in testMul self.assertEqual(str(r3), '5/12') AssertionError: '6/12' != '5/12' - 6/12 ? ^ + 5/12 ? ^ ---------------------------------------------------------------------- Ran 3 tests in 0.058s FAILED (failures=1) >>> =========== RESTART: D:\CSI33F19\Python3\Chapter2\test_Rational.py =========== ...F ====================================================================== FAIL: testMul (__main__.RationalTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "D:\CSI33F19\Python3\Chapter2\test_Rational.py", line 27, in testMul self.assertEqual(str(r3), '5/12') AssertionError: '6/12' != '5/12' - 6/12 ? ^ + 5/12 ? ^ ---------------------------------------------------------------------- Ran 4 tests in 0.010s FAILED (failures=1) >>> ============= RESTART: D:\CSI33F19\Python3\Chapter2\Rational.py ============= >>> =========== RESTART: D:\CSI33F19\Python3\Chapter2\test_Rational.py =========== .... ---------------------------------------------------------------------- Ran 4 tests in 0.064s OK >>> x = 4.56789 >>> round(x, 3) 4.568 >>> >>> w = [1, 4, -2, 4.5, 6, 'word1', 'word2'] >>> type(w) >>> w[0] 1 >>> w[5] 'word1' >>> len(w) 7 >>> x = [3.7, -3.4, 12] >>> t = x + w >>> t [3.7, -3.4, 12, 1, 4, -2, 4.5, 6, 'word1', 'word2'] >>> len(t) 10 >>> z = t[3:8] >>> z [1, 4, -2, 4.5, 6] >>> z.append(14) >>> z [1, 4, -2, 4.5, 6, 14] >>> z[2] = 10 >>> z [1, 4, 10, 4.5, 6, 14] >>> z[-1] 14 >>> z[-2] 6 >>> z[-1] = 13 >>> z [1, 4, 10, 4.5, 6, 13] >>> z.index(10) 2 >>> z.index(5) Traceback (most recent call last): File "", line 1, in z.index(5) ValueError: 5 is not in list >>> z.insert(3, 'text') >>> z [1, 4, 10, 'text', 4.5, 6, 13] >>> z.remove(1) >>> z [4, 10, 'text', 4.5, 6, 13] >>> z.remove(2) Traceback (most recent call last): File "", line 1, in z.remove(2) ValueError: list.remove(x): x not in list >>> z.pop(0) 4 >>> z [10, 'text', 4.5, 6, 13] >>> z.count(6) 1 >>> z.count(2) 0 >>> z.reverse() >>> z [13, 6, 4.5, 'text', 10] >>> z.sort() Traceback (most recent call last): File "", line 1, in z.sort() TypeError: '<' not supported between instances of 'str' and 'float' >>> z.pop(3) 'text' >>> z [13, 6, 4.5, 10] >>> z.sort() >>> z [4.5, 6, 10, 13] >>> a = z.copy() >>> z [4.5, 6, 10, 13] >>> a [4.5, 6, 10, 13] >>> a == z True >>> a[2] = 5 >>> a [4.5, 6, 5, 13] >>> z [4.5, 6, 10, 13] >>> a.clear() >>> a [] >>> z [4.5, 6, 10, 13] >>> z.reverse() >>> z [13, 10, 6, 4.5] >>> 2**20 1048576 >>> 2**50 1125899906842624 >>> 2**100 1267650600228229401496703205376 >>> 2**1000 10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376 >>> =============== RESTART: D:\CSI33F19\Python3\Chapter3\Hand.py =============== >>> c= Card('s', 10) Traceback (most recent call last): File "", line 1, in c= Card('s', 10) NameError: name 'Card' is not defined >>> from Card import Card >>> c = Card(10, 's') >>> print(c) Ten of Spades >>> c2 = card(8, 's') Traceback (most recent call last): File "", line 1, in c2 = card(8, 's') NameError: name 'card' is not defined >>> c2 = Card(8, 's') >>> c < c2 False >>> d = Card(12, 'h') >>> d >>> print(d) Queen of Hearts >>> c >> print(c) Ten of Spades >>> from Hand import * >>> h = Hand() >>> h.add(c) >>> h.add(d) >>> h.add(c2) >>> print(h) >>> h.dump() 's Cards: Ten of Spades Queen of Hearts Eight of Spades >>> h.sort() >>> h.dump() 's Cards: Ten of Spades Eight of Spades Queen of Hearts >>>