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\Chapter3\Deck.py =============== >>> x = [2, 4, 6, 8, 9] >>> x.pop() 9 >>> x [2, 4, 6, 8] >>> x [2, 4, 6, 8] >>> y =[] SyntaxError: unexpected indent >>> y = [] >>> from random import randrange >>> range(100) range(0, 100) >>> randrange(100) 83 >>> list(range(100)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99] >>> randrange(100) 56 >>> x [2, 4, 6, 8] >>> i = randrange(len(x)): SyntaxError: invalid syntax >>> i = randrange(len(x)) >>> i 3 >>> c = x.pop(i) >>> c 8 >>> y [] >>> y.append(c) >>> y [8] >>> x [2, 4, 6] >>> i = randrange(len(x)) >>> c = x.pop(i) >>> y.append(c) >>> x [2, 4] >>> y [8, 6] >>> l1 = list(range(4, 100, 5)) >>> l1 [4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 64, 69, 74, 79, 84, 89, 94, 99] >>> for i, value in enumerate(l1): print(i, value) 0 4 1 9 2 14 3 19 4 24 5 29 6 34 7 39 8 44 9 49 10 54 11 59 12 64 13 69 14 74 15 79 16 84 17 89 18 94 19 99 >>> l1 [4, 9, 14, 19, 24, 29, 34, 39, 44, 49, 54, 59, 64, 69, 74, 79, 84, 89, 94, 99] >>> for i in range(len(l1)): print(i, l1[i]) 0 4 1 9 2 14 3 19 4 24 5 29 6 34 7 39 8 44 9 49 10 54 11 59 12 64 13 69 14 74 15 79 16 84 17 89 18 94 19 99 >>> x [2, 4] >>> id(x) 2113170856776 >>> id(x[0]) 1907584064 >>> d = {} >>> type(d) >>> d['a'] = "ABC" >>> d {'a': 'ABC'} >>> d[4] = "word" >>> d {'a': 'ABC', 4: 'word'} >>> d[4] 'word' >>> d[4] = 7 >>> d {'a': 'ABC', 4: 7} >>> d['w'] = 12 >>> d {'a': 'ABC', 4: 7, 'w': 12} >>> del(d['a']) >>> d {4: 7, 'w': 12} >>> d.keys() dict_keys([4, 'w']) >>> d.values() dict_values([7, 12]) >>> d.items() dict_items([(4, 7), ('w', 12)]) >>> list(d.items()) [(4, 7), ('w', 12)] >>> hash(100) 100 >>> hash(3569876) 3569876 >>> hash(-345) -345 >>> hash('a') 3856315097565445677 >>> hash('abc') -4392308057326563456 >>> hash((2, 3)) 3713082714463740756 >>> hash([2, 3]) Traceback (most recent call last): File "", line 1, in hash([2, 3]) TypeError: unhashable type: 'list' >>>