Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 26 2016, 10:47:25) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "copyright", "credits" or "license()" for more information. >>> WARNING: The version of Tcl/Tk (8.5.9) in use may be unstable. Visit http://www.python.org/download/mac/tcltk/ for current information. ======== RESTART: /Volumes/USB20FD/csc111/lec10/guess_number_start.py ======== Enter the number of rounds: 3 round: 0 guess: 0 guess: 1 guess: 2 guess: 3 guess: 4 round: 1 guess: 0 guess: 1 guess: 2 guess: 3 guess: 4 round: 2 guess: 0 guess: 1 guess: 2 guess: 3 guess: 4 >>> ======== RESTART: /Volumes/USB20FD/csc111/lec10/guess_number_start.py ======== Enter the number of rounds: 2 Enter a integer between 0 and 9 inclusive: 6 3 is wrong, guess again. 5 is wrong, guess again. 0 is wrong, guess again. 8 is wrong, guess again. 9 is wrong, guess again. Enter a integer between 0 and 9 inclusive: 4 2 is wrong, guess again. 9 is wrong, guess again. 2 is wrong, guess again. 5 is wrong, guess again. 6 is wrong, guess again. >>> ======== RESTART: /Volumes/USB20FD/csc111/lec10/guess_number_start.py ======== Enter the number of rounds: 1 Enter a integer between 0 and 9 inclusive: 4 False 8 is wrong, guess again. False 5 is wrong, guess again. False 8 is wrong, guess again. False 7 is wrong, guess again. False You guessed my number! True 3 is wrong, guess again. True 2 is wrong, guess again. True You guessed my number! True 2 is wrong, guess again. True 1 is wrong, guess again. True 2 is wrong, guess again. True You guessed my number! True You guessed my number! True 3 is wrong, guess again. True 3 is wrong, guess again. True 1 is wrong, guess again. True 1 is wrong, guess again. True 0 is wrong, guess again. True 3 is wrong, guess again. True 9 is wrong, guess again. True 7 is wrong, guess again. True 3 is wrong, guess again. True 0 is wrong, guess again. True You guessed my number! True 3 is wrong, guess again. True 3 is wrong, guess again. True 6 is wrong, guess again. True 9 is wrong, guess again. True 8 is wrong, guess again. True 7 is wrong, guess again. True 0 is wrong, guess again. True 7 is wrong, guess again. True You guessed my number! True You guessed my number! True 9 is wrong, guess again. True 5 is wrong, guess again. True 5 is wrong, guess again. True 7 is wrong, guess again. True 2 is wrong, guess again. True 5 is wrong, guess again. True 0 is wrong, guess again. True 6 is wrong, guess again. True 6 is wrong, guess again. True 6 is wrong, guess again. True 8 is wrong, guess again. True 0 is wrong, guess again. True 7 is wrong, guess again. True 2 is wrong, guess again. True 9 is wrong, guess again. True 2 is wrong, guess again. >>> ======== RESTART: /Volumes/USB20FD/csc111/lec10/guess_number_start.py ======== Enter the number of rounds: 1 Enter a integer between 0 and 9 inclusive: 7 False 6 is wrong, guess again. False 1 is wrong, guess again. False 2 is wrong, guess again. False You guessed my number! True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. True You're done, you guessed the number. >>> ======== RESTART: /Volumes/USB20FD/csc111/lec10/guess_number_start.py ======== Enter the number of rounds: 1 Enter a integer between 0 and 9 inclusive: 4 9 is wrong, guess again. 0 is wrong, guess again. 5 is wrong, guess again. 2 is wrong, guess again. 5 is wrong, guess again. 0 is wrong, guess again. 7 is wrong, guess again. 7 is wrong, guess again. 5 is wrong, guess again. You guessed my number! You're done, you guessed the number. >>> ======== RESTART: /Volumes/USB20FD/csc111/lec10/guess_number_start.py ======== Enter the number of rounds: 1 Enter a integer between 0 and 9 inclusive: 8 5 is wrong, guess again. 7 is wrong, guess again. 3 is wrong, guess again. 6 is wrong, guess again. 0 is wrong, guess again. 1 is wrong, guess again. 5 is wrong, guess again. 6 is wrong, guess again. 7 is wrong, guess again. 9 is wrong, guess again. 2 is wrong, guess again. 6 is wrong, guess again. 5 is wrong, guess again. You guessed my number! You're done, you guessed the number. >>> ======== RESTART: /Volumes/USB20FD/csc111/lec10/guess_number_start.py ======== Enter the number of rounds: 51 Enter a integer between 0 and 9 inclusive: 51 0 is wrong, guess again. 2 is wrong, guess again. 6 is wrong, guess again. 4 is wrong, guess again. 0 is wrong, guess again. 3 is wrong, guess again. 7 is wrong, guess again. 8 is wrong, guess again. 5 is wrong, guess again. 9 is wrong, guess again. 2 is wrong, guess again. 8 is wrong, guess again. 8 is wrong, guess again. 0 is wrong, guess again. 4 is wrong, guess again. 1 is wrong, guess again. 7 is wrong, guess again. 5 is wrong, guess again. 3 is wrong, guess again. 7 is wrong, guess again. 3 is wrong, guess again. 2 is wrong, guess again. 5 is wrong, guess again. 7 is wrong, guess again. 9 is wrong, guess again. 8 is wrong, guess again. 0 is wrong, guess again. 5 is wrong, guess again. 2 is wrong, guess again. 5 is wrong, guess again. 0 is wrong, guess again. 4 is wrong, guess again. 6 is wrong, guess again. 2 is wrong, guess again. 0 is wrong, guess again. 5 is wrong, guess again. 6 is wrong, guess again. 8 is wrong, guess again. 9 is wrong, guess again. 2 is wrong, guess again. 0 is wrong, guess again. 9 is wrong, guess again. 0 is wrong, guess again. 2 is wrong, guess again. 5 is wrong, guess again. 1 is wrong, guess again. 7 is wrong, guess again. 8 is wrong, guess again. 7 is wrong, guess again. 5 is wrong, guess again. You're done, you guessed the number. Enter a integer between 0 and 9 inclusive: Traceback (most recent call last): File "/Volumes/USB20FD/csc111/lec10/guess_number_start.py", line 43, in main() File "/Volumes/USB20FD/csc111/lec10/guess_number_start.py", line 21, in main number = eval(input("Enter a integer between 0 and 9 inclusive: ")) File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/idlelib/PyShell.py", line 1386, in readline line = self._line_buffer or self.shell.readline() KeyboardInterrupt >>> ======== RESTART: /Volumes/USB20FD/csc111/lec10/guess_number_start.py ======== Enter the number of rounds: 1 Enter a integer between 0 and 9 inclusive: 60 2 is wrong, guess again. 8 is wrong, guess again. 4 is wrong, guess again. 9 is wrong, guess again. 0 is wrong, guess again. 1 is wrong, guess again. 1 is wrong, guess again. 7 is wrong, guess again. 0 is wrong, guess again. 7 is wrong, guess again. 1 is wrong, guess again. 7 is wrong, guess again. 5 is wrong, guess again. 8 is wrong, guess again. 7 is wrong, guess again. 3 is wrong, guess again. 6 is wrong, guess again. 7 is wrong, guess again. 0 is wrong, guess again. 6 is wrong, guess again. 9 is wrong, guess again. 3 is wrong, guess again. 9 is wrong, guess again. 7 is wrong, guess again. 2 is wrong, guess again. 1 is wrong, guess again. 1 is wrong, guess again. 2 is wrong, guess again. 0 is wrong, guess again. 4 is wrong, guess again. 9 is wrong, guess again. 0 is wrong, guess again. 5 is wrong, guess again. 3 is wrong, guess again. 9 is wrong, guess again. 7 is wrong, guess again. 0 is wrong, guess again. 7 is wrong, guess again. 2 is wrong, guess again. 1 is wrong, guess again. 1 is wrong, guess again. 9 is wrong, guess again. 4 is wrong, guess again. 5 is wrong, guess again. 1 is wrong, guess again. 4 is wrong, guess again. 9 is wrong, guess again. 8 is wrong, guess again. 3 is wrong, guess again. 7 is wrong, guess again. >>> >>> >>> >>> string = "Smith College" >>> lst = ["zero","one","two","three","four"] >>> >>> my_lst = ["three",3] >>> # the elements of strings are characters >>> # the elements of lists are anything! >>> >>> # 1) length >>> len(string) 13 >>> len(lst) 5 >>> # 2) concatenation >>> >>> string2 = " is in Northampton" >>> string + string2 'Smith College is in Northampton' >>> string2 + string ' is in NorthamptonSmith College' >>> type(string) >>> type(lst) >>> >>> lst2 = ["five","six","seven","eight"] >>> lst + lst2 ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'] >>> lst2 + lst ['five', 'six', 'seven', 'eight', 'zero', 'one', 'two', 'three', 'four'] >>> >>> # 3) indexing >>> string 'Smith College' >>> string[0] 'S' >>> string[3] 't' >>> string[-1] 'e' >>> lst ['zero', 'one', 'two', 'three', 'four'] >>> lst[0] 'zero' >>> lst[3] 'three' >>> lst[-1] 'four' >>> >>> >>> # 4) count >>> string 'Smith College' >>> string.count("e") 2 >>> lst ['zero', 'one', 'two', 'three', 'four'] >>> lst.count("one") 1 >>> >>> # differences begin >>> string.split() ['Smith', 'College'] >>> type(string.split()) >>> >>> lst.split() Traceback (most recent call last): File "", line 1, in lst.split() AttributeError: 'list' object has no attribute 'split' >>> >>> =============================== RESTART: Shell =============================== >>> =============================== RESTART: Shell =============================== >>> >>> string = "Smith College" >>> string.lower() 'smith college' >>> string.upper() 'SMITH COLLEGE' >>> >>> >>> >>> # we will use the ideas behind range and indexing to do slicing >>> # the result of slicing is a substring >>> string[0:5] # include start and exclude end 'Smith' >>> string[3:7] 'th C' >>> string[7] 'o' >>> string[0:5] 'Smith' >>> string[5] ' ' >>> string[:5] # no start defined, start from the beginning 'Smith' >>> >>> string[5:] # no end defined, go all the way to the end ' College' >>> string[:] 'Smith College' >>> string 'Smith College' >>> string + string 'Smith CollegeSmith College' >>> string[:5]*2 'SmithSmith' >>> string[:5][1:3] 'mi' >>> ================ RESTART: /Users/ssheehan/Documents/month.py ================ >>> month_name(1) 1 >>> months[0:3] 'Jan' >>> months[3:6] 'Feb' >>> months[8*3:9*3] 'Sep' >>> months[24:27] 'Sep' >>> months[9*3:10*3] 'Oct' >>> months[(9-1)*3:(10-1)*3] 'Sep' >>> ================ RESTART: /Users/ssheehan/Documents/month.py ================ >>> month_name(9) Sep >>> month_name(10) Oct >>> month_name(1) Jan >>> month_name(5) May >>> month_name(12) Dec >>> ================ RESTART: /Users/ssheehan/Documents/month.py ================ >>> month_name(0) >>> month_name(13) >>> ================ RESTART: /Users/ssheehan/Documents/month.py ================ >>> month_name(13) that month doesn't exist >>> month_name(-10) that month doesn't exist >>> month_name(0) that month doesn't exist >>> month_name(3) Mar >>> month_name(3.5) Traceback (most recent call last): File "", line 1, in month_name(3.5) File "/Users/ssheehan/Documents/month.py", line 10, in month_name print(months[start:start+3]) TypeError: slice indices must be integers or None or have an __index__ method >>>