From 69a59cea0051cd0c83b7e13f4c08adcabe4f26ef Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 12:57:58 -0500 Subject: [PATCH 01/17] Completed hello world file --- src/hello.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hello.py b/src/hello.py index 268998dfc7..b35a371df2 100644 --- a/src/hello.py +++ b/src/hello.py @@ -1 +1,3 @@ -# Print "Hello, world!" to your terminal \ No newline at end of file +# Print "Hello, world!" to your terminal + +print("hello world!") \ No newline at end of file From 113a97186f10b15611ef0c52e448dc73b4beef70 Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 13:46:51 -0500 Subject: [PATCH 02/17] complted bignum file --- src/bignum.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bignum.py b/src/bignum.py index c020928d63..3c85ea3651 100644 --- a/src/bignum.py +++ b/src/bignum.py @@ -1,4 +1,6 @@ # Print out 2 to the 65536 power # (try doing the same thing in the JS console and see what it outputs) -# YOUR CODE HERE \ No newline at end of file +# YOUR CODE HERE + +print(2 ** 65536) \ No newline at end of file From b19466257d3aa9d712060ba36de1812e50757596 Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 13:50:53 -0500 Subject: [PATCH 03/17] completed datatypes file --- src/datatypes.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/datatypes.py b/src/datatypes.py index 54178a241e..28507e1b83 100644 --- a/src/datatypes.py +++ b/src/datatypes.py @@ -14,8 +14,9 @@ # Write a print statement that combines x + y into the integer value 12 # YOUR CODE HERE - +print(x + int(y)) # Write a print statement that combines x + y into the string value 57 -# YOUR CODE HERE \ No newline at end of file +# YOUR CODE HERE +print(f'{x}{y}') \ No newline at end of file From 1d7754c9fc5955abe6561bd8060b8b44e5e382b9 Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 14:17:25 -0500 Subject: [PATCH 04/17] completed the modules file --- src/modules.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/modules.py b/src/modules.py index 97eba053c7..497293fe73 100644 --- a/src/modules.py +++ b/src/modules.py @@ -10,22 +10,24 @@ # Print out the command line arguments in sys.argv, one per line: # YOUR CODE HERE - +for i in sys.argv: + print(i) # Print out the OS platform you're using: # YOUR CODE HERE - +print(sys.platform) # Print out the version of Python you're using: # YOUR CODE HERE - +print(sys.version) import os # See the docs for the OS module: https://docs.python.org/3.7/library/os.html # Print the current process ID # YOUR CODE HERE - +print(os.getpid()) # Print the current working directory (cwd): # YOUR CODE HERE - +print(os.getcwd()) # Print out your machine's login name # YOUR CODE HERE +print(os.getlogin()) \ No newline at end of file From d028df6fbe60166a9eda1c95a3f090394bb23eab Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 14:27:12 -0500 Subject: [PATCH 05/17] compelted the printing file --- src/printing.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/printing.py b/src/printing.py index 06aaa7ff16..5304812e6d 100644 --- a/src/printing.py +++ b/src/printing.py @@ -11,7 +11,9 @@ # Using the printf operator (%), print the following feeding in the values of x, # y, and z: # x is 10, y is 2.25, z is "I like turtles!" - +print('x is %s, y is %s, z is "%s"' % (x, y, z)) # Use the 'format' string method to print the same thing - -# Finally, print the same thing using an f-string \ No newline at end of file +string = 'x is {}, y is {}, z is "{}"' +print(string.format(x, y, z)) +# Finally, print the same thing using an f-string +print(f'x is {x}, y is {y}, z is "{z}"') \ No newline at end of file From 894fdbabce480c2287d12a792d61d404d472ab3c Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 14:37:53 -0500 Subject: [PATCH 06/17] compeleted lists file --- src/lists.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lists.py b/src/lists.py index 6b7d307182..eae3e03908 100644 --- a/src/lists.py +++ b/src/lists.py @@ -8,22 +8,28 @@ # Change x so that it is [1, 2, 3, 4] # YOUR CODE HERE +x.append(4) print(x) # Using y, change x so that it is [1, 2, 3, 4, 8, 9, 10] # YOUR CODE HERE +x.extend(y) print(x) # Change x so that it is [1, 2, 3, 4, 9, 10] # YOUR CODE HERE +x.remove(8) print(x) # Change x so that it is [1, 2, 3, 4, 9, 99, 10] # YOUR CODE HERE +x.insert(5, 99) print(x) # Print the length of list x # YOUR CODE HERE - +print(len(x)) # Print all the values in x multiplied by 1000 -# YOUR CODE HERE \ No newline at end of file +# YOUR CODE HERE +for i in x: + print(i * 1000) \ No newline at end of file From dedff9fa048eb99cea5db5baada7bd2812ff5057 Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 14:44:11 -0500 Subject: [PATCH 07/17] completed the tuples file --- src/tuples.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tuples.py b/src/tuples.py index 016e540801..98048bb0a4 100644 --- a/src/tuples.py +++ b/src/tuples.py @@ -35,10 +35,12 @@ def dist(a, b): # Write a function `print_tuple` that prints all the values in a tuple # YOUR CODE HERE - +def print_tuple(t): + for i in t: + print(i) t = (1, 2, 5, 7, 99) print_tuple(t) # Prints 1 2 5 7 99, one per line # Declare a tuple of 1 element then print it -u = (1) # What needs to be added to make this work? +u = (1,) # What needs to be added to make this work? print_tuple(u) From 317f64bc978adb984e11fcfa8b3a8a8b5200bc7b Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 14:55:34 -0500 Subject: [PATCH 08/17] completed the slices file --- src/slices.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/slices.py b/src/slices.py index 5e0b3bd8ee..b8275947a8 100644 --- a/src/slices.py +++ b/src/slices.py @@ -12,26 +12,26 @@ a = [2, 4, 1, 7, 9, 6] # Output the second element: 4: -print() +print(a[1]) # Output the second-to-last element: 9 -print() +print(a[-2]) # Output the last three elements in the array: [7, 9, 6] -print() +print(a[-3:]) # Output the two middle elements in the array: [1, 7] -print() +print(a[2:-2]) # Output every element except the first one: [4, 1, 7, 9, 6] -print() +print(a[1:]) # Output every element except the last one: [2, 4, 1, 7, 9] -print() +print(a[:-1]) # For string s... s = "Hello, world!" # Output just the 8th-12th characters: "world" -print() \ No newline at end of file +print(s[7:-1]) \ No newline at end of file From dc4814cf7a18de8043f08a19e765dde8f31bf993 Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 15:28:46 -0500 Subject: [PATCH 09/17] completed the comprehensions file --- src/comprehensions.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/comprehensions.py b/src/comprehensions.py index 67eb742e50..9f512a3dbd 100644 --- a/src/comprehensions.py +++ b/src/comprehensions.py @@ -10,14 +10,14 @@ # Write a list comprehension to produce the array [1, 2, 3, 4, 5] -y = [] +y = [x+1 for x in range(5)] print (y) # Write a list comprehension to produce the cubes of the numbers 0-9: # [0, 1, 8, 27, 64, 125, 216, 343, 512, 729] -y = [] +y = [x**3 for x in range(10)] print(y) @@ -26,7 +26,7 @@ a = ["foo", "bar", "baz"] -y = [] +y = [x.upper() for x in a] print(y) @@ -36,6 +36,6 @@ x = input("Enter comma-separated numbers: ").split(',') # What do you need between the square brackets to make it work? -y = [] +y = [b for a, b in enumerate(x) if a % 2 == 0] print(y) \ No newline at end of file From 6bc3d9c58e268c67a4afbdbee9725ec5d62f15d9 Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 16:00:10 -0500 Subject: [PATCH 10/17] finished the dictionaries file --- src/dictionaries.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/dictionaries.py b/src/dictionaries.py index 687a2ae2dc..940655aac0 100644 --- a/src/dictionaries.py +++ b/src/dictionaries.py @@ -35,10 +35,16 @@ # Add a new waypoint to the list # YOUR CODE HERE - +waypoints.append({ "lat": 45, "lon": -25, "name": "Awesome town"}) +print(waypoints) # Modify the dictionary with name "a place" such that its longitude # value is -130 and change its name to "not a real place" # YOUR CODE HERE - +waypoints[0]["lon"] = -130 +waypoints[0]["name"] = "not a real place" +print(waypoints) # Write a loop that prints out all the field values for all the waypoints -# YOUR CODE HERE \ No newline at end of file +# YOUR CODE HERE +for a in waypoints: + for b in a: + print(a[b]) \ No newline at end of file From f524166e06ed359f4c237e37db064dd94f20fe03 Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 16:05:42 -0500 Subject: [PATCH 11/17] finished functions file --- src/functions.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/functions.py b/src/functions.py index 5830100c2c..d95b1d3a7c 100644 --- a/src/functions.py +++ b/src/functions.py @@ -1,7 +1,11 @@ # Write a function is_even that will return true if the passed-in number is even. # YOUR CODE HERE - +def is_even(num): + if num % 2 == 0: + return True + else: + return False # Read a number from the keyboard num = input("Enter a number: ") num = int(num) @@ -9,4 +13,7 @@ # Print out "Even!" if the number is even. Otherwise print "Odd" # YOUR CODE HERE - +if is_even(num): + print('Even!') +else: + print('Odd') From 7d8e12c3186c42b9581e20fb77b6c89d2422a18a Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 16:50:44 -0500 Subject: [PATCH 12/17] redid the last comprehensions question --- src/comprehensions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/comprehensions.py b/src/comprehensions.py index 9f512a3dbd..3eea735d91 100644 --- a/src/comprehensions.py +++ b/src/comprehensions.py @@ -36,6 +36,6 @@ x = input("Enter comma-separated numbers: ").split(',') # What do you need between the square brackets to make it work? -y = [b for a, b in enumerate(x) if a % 2 == 0] +y = [a for a in x if int(a) % 2 == 0] print(y) \ No newline at end of file From dd2583fbb097834d220919dd0f54f02454790ff1 Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 17:38:06 -0500 Subject: [PATCH 13/17] finished the args file --- src/args.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/args.py b/src/args.py index b23783d530..52f83e1c03 100644 --- a/src/args.py +++ b/src/args.py @@ -5,13 +5,19 @@ # the sum. This is what you'd consider to be a regular, normal function. # YOUR CODE HERE - +def f1(a, b): + return a + b print(f1(1, 2)) # Write a function f2 that takes any number of integer arguments and prints the # sum. Google for "python arbitrary arguments" and look for "*args" # YOUR CODE HERE +def f2(*args): + z = 0 + for a in args: + z += a + return z print(f2(1)) # Should print 1 print(f2(1, 3)) # Should print 4 @@ -21,14 +27,15 @@ a = [7, 6, 5, 4] # What thing do you have to add to make this work? -print(f2(a)) # Should print 22 +print(f2(*a)) # Should print 22 # Write a function f3 that accepts either one or two arguments. If one argument, # it returns that value plus 1. If two arguments, it returns the sum of the # arguments. Google "python default arguments" for a hint. # YOUR CODE HERE - +def f3(farg, sarg = 1): + return farg + sarg print(f3(1, 2)) # Should print 3 print(f3(8)) # Should print 9 @@ -42,7 +49,9 @@ # Google "python keyword arguments". # YOUR CODE HERE - +def f4(**kwargs): + for x, y in kwargs.items(): + print(f'key: {x}, value: {y}') # Should print # key: a, value: 12 # key: b, value: 30 @@ -60,4 +69,4 @@ } # What thing do you have to add to make this work? -f4(d) \ No newline at end of file +f4(**d) \ No newline at end of file From e078605e1eb66422154f67923bf9dd200ff240ab Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 17:46:32 -0500 Subject: [PATCH 14/17] completed the scopes file --- src/scopes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/scopes.py b/src/scopes.py index 339ae1915e..59c247037a 100644 --- a/src/scopes.py +++ b/src/scopes.py @@ -5,6 +5,7 @@ x = 12 def changeX(): + global x x = 99 changeX() @@ -19,6 +20,7 @@ def outer(): y = 120 def inner(): + nonlocal y y = 999 inner() From ba4927b5f532dd99611920c177491b09265da091 Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 18:01:18 -0500 Subject: [PATCH 15/17] completed the file_io file --- src/bar.txt | 3 +++ src/file_io.py | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 src/bar.txt diff --git a/src/bar.txt b/src/bar.txt new file mode 100644 index 0000000000..2570626e1e --- /dev/null +++ b/src/bar.txt @@ -0,0 +1,3 @@ +This is a test +This is another test +This should have three lines \ No newline at end of file diff --git a/src/file_io.py b/src/file_io.py index f0ddeb0020..2ddd102cf1 100644 --- a/src/file_io.py +++ b/src/file_io.py @@ -9,10 +9,15 @@ # Print all the contents of the file, then close the file # YOUR CODE HERE - +f = open('foo.txt', 'r') +print(f.read()) +f.close() # Open up a file called "bar.txt" (which doesn't exist yet) for # writing. Write three lines of arbitrary content to that file, # then close the file. Open up "bar.txt" and inspect it to make # sure that it contains what you expect it to contain -# YOUR CODE HERE \ No newline at end of file +# YOUR CODE HERE +b = open('bar.txt', 'w') +b.write('This is a test\nThis is another test\nThis should have three lines') +b.close() \ No newline at end of file From 83d9c7fbbc046824a81ca3180ebac03faf684e53 Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Mon, 22 Apr 2019 19:03:38 -0500 Subject: [PATCH 16/17] completed the cal file --- src/cal.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/cal.py b/src/cal.py index 7d4a0a3417..a9af288924 100644 --- a/src/cal.py +++ b/src/cal.py @@ -21,4 +21,25 @@ import sys import calendar -from datetime import datetime \ No newline at end of file +from datetime import datetime + +now = datetime.now() + +def createCal(month = now.month, year=now.year): + c = calendar.TextCalendar(firstweekday=6) + cal = c.formatmonth(year, month) + print(cal) + +if len(sys.argv) > 1: + if len(sys.argv) > 2: + if not sys.argv[1].isdecimal(): + print('Please input the month and year as numbers') + else: + createCal(int(sys.argv[1]), int(sys.argv[2])) + else: + if not sys.argv[1].isdecimal(): + print('Please input the month and year as numbers') + else: + createCal(int(sys.argv[1])) +else: + createCal() \ No newline at end of file From 7d8befa183896f0c4fdcf5fd236c5bf293775fa7 Mon Sep 17 00:00:00 2001 From: Modesto Tamayo Date: Tue, 23 Apr 2019 13:08:12 -0500 Subject: [PATCH 17/17] completed classes file --- Pipfile | 1 + Pipfile.lock | 117 +++++++++++++++++++++++++++++++++++++++++++++++- src/classes.py | 24 ++++++++-- src/lists.py | 2 +- src/printing.py | 6 +-- 5 files changed, 141 insertions(+), 9 deletions(-) diff --git a/Pipfile b/Pipfile index 3e601a5316..8698f323e1 100644 --- a/Pipfile +++ b/Pipfile @@ -6,6 +6,7 @@ name = "pypi" [packages] [dev-packages] +pylint = "*" [requires] python_version = "3" diff --git a/Pipfile.lock b/Pipfile.lock index a36a2c8975..8f57a4822c 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "4e61a4ba9e6f02f50f68627253af5ababd9b1b4c1e10294e48158e1f42c0c5a6" + "sha256": "8159f2897c60bb49d8c3dba897a90e1c7946f529f7c725987f3a3bea8156abdc" }, "pipfile-spec": 6, "requires": { @@ -16,5 +16,118 @@ ] }, "default": {}, - "develop": {} + "develop": { + "astroid": { + "hashes": [ + "sha256:6560e1e1749f68c64a4b5dee4e091fce798d2f0d84ebe638cf0e0585a343acf4", + "sha256:b65db1bbaac9f9f4d190199bb8680af6f6f84fd3769a5ea883df8a91fe68b4c4" + ], + "version": "==2.2.5" + }, + "colorama": { + "hashes": [ + "sha256:05eed71e2e327246ad6b38c540c4a3117230b19679b875190486ddd2d721422d", + "sha256:f8ac84de7840f5b9c4e3347b3c1eaa50f7e49c2b07596221daec5edaabbd7c48" + ], + "markers": "sys_platform == 'win32'", + "version": "==0.4.1" + }, + "isort": { + "hashes": [ + "sha256:01cb7e1ca5e6c5b3f235f0385057f70558b70d2f00320208825fa62887292f43", + "sha256:268067462aed7eb2a1e237fcb287852f22077de3fb07964e87e00f829eea2d1a" + ], + "version": "==4.3.17" + }, + "lazy-object-proxy": { + "hashes": [ + "sha256:0ce34342b419bd8f018e6666bfef729aec3edf62345a53b537a4dcc115746a33", + "sha256:1b668120716eb7ee21d8a38815e5eb3bb8211117d9a90b0f8e21722c0758cc39", + "sha256:209615b0fe4624d79e50220ce3310ca1a9445fd8e6d3572a896e7f9146bbf019", + "sha256:27bf62cb2b1a2068d443ff7097ee33393f8483b570b475db8ebf7e1cba64f088", + "sha256:27ea6fd1c02dcc78172a82fc37fcc0992a94e4cecf53cb6d73f11749825bd98b", + "sha256:2c1b21b44ac9beb0fc848d3993924147ba45c4ebc24be19825e57aabbe74a99e", + "sha256:2df72ab12046a3496a92476020a1a0abf78b2a7db9ff4dc2036b8dd980203ae6", + "sha256:320ffd3de9699d3892048baee45ebfbbf9388a7d65d832d7e580243ade426d2b", + "sha256:50e3b9a464d5d08cc5227413db0d1c4707b6172e4d4d915c1c70e4de0bbff1f5", + "sha256:5276db7ff62bb7b52f77f1f51ed58850e315154249aceb42e7f4c611f0f847ff", + "sha256:61a6cf00dcb1a7f0c773ed4acc509cb636af2d6337a08f362413c76b2b47a8dd", + "sha256:6ae6c4cb59f199d8827c5a07546b2ab7e85d262acaccaacd49b62f53f7c456f7", + "sha256:7661d401d60d8bf15bb5da39e4dd72f5d764c5aff5a86ef52a042506e3e970ff", + "sha256:7bd527f36a605c914efca5d3d014170b2cb184723e423d26b1fb2fd9108e264d", + "sha256:7cb54db3535c8686ea12e9535eb087d32421184eacc6939ef15ef50f83a5e7e2", + "sha256:7f3a2d740291f7f2c111d86a1c4851b70fb000a6c8883a59660d95ad57b9df35", + "sha256:81304b7d8e9c824d058087dcb89144842c8e0dea6d281c031f59f0acf66963d4", + "sha256:933947e8b4fbe617a51528b09851685138b49d511af0b6c0da2539115d6d4514", + "sha256:94223d7f060301b3a8c09c9b3bc3294b56b2188e7d8179c762a1cda72c979252", + "sha256:ab3ca49afcb47058393b0122428358d2fbe0408cf99f1b58b295cfeb4ed39109", + "sha256:bd6292f565ca46dee4e737ebcc20742e3b5be2b01556dafe169f6c65d088875f", + "sha256:cb924aa3e4a3fb644d0c463cad5bc2572649a6a3f68a7f8e4fbe44aaa6d77e4c", + "sha256:d0fc7a286feac9077ec52a927fc9fe8fe2fabab95426722be4c953c9a8bede92", + "sha256:dad32f75a0d8b7c4ad1143d3985695ba6bc43ef7c8ed442b98370b950cf32567", + "sha256:ddc34786490a6e4ec0a855d401034cbd1242ef186c20d79d2166d6a4bd449577", + "sha256:e34b155e36fa9da7e1b7c738ed7767fc9491a62ec6af70fe9da4a057759edc2d", + "sha256:e5b9e8f6bda48460b7b143c3821b21b452cb3a835e6bbd5dd33aa0c8d3f5137d", + "sha256:e81ebf6c5ee9684be8f2c87563880f93eedd56dd2b6146d8a725b50b7e5adb0f", + "sha256:eb91be369f945f10d3a49f5f9be8b3d0b93a4c2be8f8a5b83b0571b8123e0a7a", + "sha256:f460d1ceb0e4a5dcb2a652db0904224f367c9b3c1470d5a7683c0480e582468b" + ], + "version": "==1.3.1" + }, + "mccabe": { + "hashes": [ + "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", + "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f" + ], + "version": "==0.6.1" + }, + "pylint": { + "hashes": [ + "sha256:5d77031694a5fb97ea95e828c8d10fc770a1df6eb3906067aaed42201a8a6a09", + "sha256:723e3db49555abaf9bf79dc474c6b9e2935ad82230b10c1138a71ea41ac0fff1" + ], + "index": "pypi", + "version": "==2.3.1" + }, + "six": { + "hashes": [ + "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", + "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" + ], + "version": "==1.12.0" + }, + "typed-ast": { + "hashes": [ + "sha256:04894d268ba6eab7e093d43107869ad49e7b5ef40d1a94243ea49b352061b200", + "sha256:16616ece19daddc586e499a3d2f560302c11f122b9c692bc216e821ae32aa0d0", + "sha256:252fdae740964b2d3cdfb3f84dcb4d6247a48a6abe2579e8029ab3be3cdc026c", + "sha256:2af80a373af123d0b9f44941a46df67ef0ff7a60f95872412a145f4500a7fc99", + "sha256:2c88d0a913229a06282b285f42a31e063c3bf9071ff65c5ea4c12acb6977c6a7", + "sha256:2ea99c029ebd4b5a308d915cc7fb95b8e1201d60b065450d5d26deb65d3f2bc1", + "sha256:3d2e3ab175fc097d2a51c7a0d3fda442f35ebcc93bb1d7bd9b95ad893e44c04d", + "sha256:4766dd695548a15ee766927bf883fb90c6ac8321be5a60c141f18628fb7f8da8", + "sha256:56b6978798502ef66625a2e0f80cf923da64e328da8bbe16c1ff928c70c873de", + "sha256:5cddb6f8bce14325b2863f9d5ac5c51e07b71b462361fd815d1d7706d3a9d682", + "sha256:644ee788222d81555af543b70a1098f2025db38eaa99226f3a75a6854924d4db", + "sha256:64cf762049fc4775efe6b27161467e76d0ba145862802a65eefc8879086fc6f8", + "sha256:68c362848d9fb71d3c3e5f43c09974a0ae319144634e7a47db62f0f2a54a7fa7", + "sha256:6c1f3c6f6635e611d58e467bf4371883568f0de9ccc4606f17048142dec14a1f", + "sha256:b213d4a02eec4ddf622f4d2fbc539f062af3788d1f332f028a2e19c42da53f15", + "sha256:bb27d4e7805a7de0e35bd0cb1411bc85f807968b2b0539597a49a23b00a622ae", + "sha256:c9d414512eaa417aadae7758bc118868cd2396b0e6138c1dd4fda96679c079d3", + "sha256:f0937165d1e25477b01081c4763d2d9cdc3b18af69cb259dd4f640c9b900fe5e", + "sha256:fb96a6e2c11059ecf84e6741a319f93f683e440e341d4489c9b161eca251cf2a", + "sha256:fc71d2d6ae56a091a8d94f33ec9d0f2001d1cb1db423d8b4355debfe9ce689b7" + ], + "markers": "implementation_name == 'cpython'", + "version": "==1.3.4" + }, + "wrapt": { + "hashes": [ + "sha256:4aea003270831cceb8a90ff27c4031da6ead7ec1886023b80ce0dfe0adf61533", + "sha256:cda94c8cbae03ef452450c2faaf0a122b89c3c028ee37f5c48fa8f1f6d70de45" + ], + "version": "==1.11.1" + } + } } diff --git a/src/classes.py b/src/classes.py index e4425325cd..1a012e70a8 100644 --- a/src/classes.py +++ b/src/classes.py @@ -2,21 +2,39 @@ # constructor # YOUR CODE HERE - +class LatLon: + def __init__(self, lat, lon): + self.lat = lat + self.lon = lon # Make a class Waypoint that can be passed parameters `name`, `lat`, and `lon` to the # constructor. It should inherit from LatLon. Look up the `super` method. # YOUR CODE HERE +class Waypoint(LatLon): + def __init__(self, name, lat, lon): + super().__init__(lat, lon) + self.name = name + + def __str__(self): + return ' "'+self.name+'", '+str(self.lat)+', '+str(self.lon)+' ' # Make a class Geocache that can be passed parameters `name`, `difficulty`, # `size`, `lat`, and `lon` to the constructor. What should it inherit from? # YOUR CODE HERE +class Geocache(Waypoint): + def __init__(self, name, difficulty, size, lat, lon): + super().__init__(name, lat, lon) + self.difficulty = difficulty + self.size = size + + def __str__(self): + return ' "'+self.name+'", diff '+str(self.difficulty)+', size '+str(self.size)+', '+str(self.lat)+', '+str(self.lon)+' ' # Make a new waypoint and print it out: "Catacombs", 41.70505, -121.51521 # YOUR CODE HERE - +waypoint = Waypoint("Catacombs", 41.70505, -121.51521) # Without changing the following line, how can you make it print into something # more human-readable? Hint: Look up the `object.__str__` method print(waypoint) @@ -24,6 +42,6 @@ # Make a new geocache "Newberry Views", diff 1.5, size 2, 44.052137, -121.41556 # YOUR CODE HERE - +geocache = Geocache("Newberry Views", 1.5, 2, 44.052137, -121.41556) # Print it--also make this print more nicely print(geocache) diff --git a/src/lists.py b/src/lists.py index eae3e03908..75d86d8850 100644 --- a/src/lists.py +++ b/src/lists.py @@ -23,7 +23,7 @@ # Change x so that it is [1, 2, 3, 4, 9, 99, 10] # YOUR CODE HERE -x.insert(5, 99) +x.insert(-1, 99) print(x) # Print the length of list x diff --git a/src/printing.py b/src/printing.py index 5304812e6d..67eb26dc5a 100644 --- a/src/printing.py +++ b/src/printing.py @@ -11,9 +11,9 @@ # Using the printf operator (%), print the following feeding in the values of x, # y, and z: # x is 10, y is 2.25, z is "I like turtles!" -print('x is %s, y is %s, z is "%s"' % (x, y, z)) +print('x is %s, y is %s, z is "%s"' % (x, round(y,2), z)) # Use the 'format' string method to print the same thing -string = 'x is {}, y is {}, z is "{}"' +string = 'x is {}, y is {:.2f}, z is "{}"' print(string.format(x, y, z)) # Finally, print the same thing using an f-string -print(f'x is {x}, y is {y}, z is "{z}"') \ No newline at end of file +print(f'x is {x}, y is {y:.2f}, z is "{z}"') \ No newline at end of file