From 04c74ea904ac40b7f1c99d3c930964babe474719 Mon Sep 17 00:00:00 2001 From: rootrUW Date: Wed, 26 Dec 2018 11:40:23 -1000 Subject: [PATCH 01/12] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 43f9e6b..143b712 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -# Class Repository Template +# Winter 2019 Python 210 A Repository -**WARNING** This is a template -- it is not an actual class repo. Students should find the proper repo for their class, and make a fork of that. +Class Repository Class notes are published here: -This is a repo that serves as a template for a repository for a particular -instance of a class for the [UWPCE Python Certificate](https://www.pce.uw.edu/certificates/python-programming). +https://canvas.uw.edu/courses/1247283/pages/classnotes (External Link) -Make a copy of this repo for each class, so that it can be used by the class to -share information and for students to submit their work. +This repository is used for submitting and reviewing student's work for the Winter 2019 classrooom section of University of Washington Continuing and Professional Education Python certificate program + +https://www.pce.uw.edu/certificates/python-programming (External Link) ## Structure of the Repo From ce63cc540619acdbc5416ded37a9f677e92bef32 Mon Sep 17 00:00:00 2001 From: Randal Root Date: Wed, 26 Dec 2018 11:48:42 -1000 Subject: [PATCH 02/12] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 143b712..ba4d5fe 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,4 @@ The class repo has three top level directories: * `students`: Used for the students to submit their work. Each student will create a directory, then store work for each exercise in a subdirectory of that. +_Please review the instructions on how to use this site here:_ [GitHub Instructions](https://uwpce-pythoncert.github.io/PythonCertDevel/modules/Git.html) From 7fb207fe6c022b395003447daee74a9384062a9c Mon Sep 17 00:00:00 2001 From: Randal Root Date: Wed, 2 Jan 2019 12:39:25 -0800 Subject: [PATCH 03/12] Create sadfsa --- students/sadfsa | 1 + 1 file changed, 1 insertion(+) create mode 100644 students/sadfsa diff --git a/students/sadfsa b/students/sadfsa new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/students/sadfsa @@ -0,0 +1 @@ + From 17a46029c7dcf0ab734aaae2276bda4ac1f5bba1 Mon Sep 17 00:00:00 2001 From: Randal Root Date: Wed, 2 Jan 2019 12:39:38 -0800 Subject: [PATCH 04/12] Delete sadfsa --- students/sadfsa | 1 - 1 file changed, 1 deletion(-) delete mode 100644 students/sadfsa diff --git a/students/sadfsa b/students/sadfsa deleted file mode 100644 index 8b13789..0000000 --- a/students/sadfsa +++ /dev/null @@ -1 +0,0 @@ - From 4d941b760f3dd6d05da5e31a6f2129dd3b29305a Mon Sep 17 00:00:00 2001 From: Randal Root Date: Wed, 2 Jan 2019 13:08:12 -0800 Subject: [PATCH 05/12] Create ReadMe.txt --- students/RRoot/ReadMe.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 students/RRoot/ReadMe.txt diff --git a/students/RRoot/ReadMe.txt b/students/RRoot/ReadMe.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/students/RRoot/ReadMe.txt @@ -0,0 +1 @@ + From 91c947ac976be8ef46406ea21651bb239e656d51 Mon Sep 17 00:00:00 2001 From: Randal Root Date: Wed, 2 Jan 2019 13:08:43 -0800 Subject: [PATCH 06/12] Update ReadMe.txt --- students/RRoot/ReadMe.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/students/RRoot/ReadMe.txt b/students/RRoot/ReadMe.txt index 8b13789..9305c3e 100644 --- a/students/RRoot/ReadMe.txt +++ b/students/RRoot/ReadMe.txt @@ -1 +1 @@ - +This where I will put my homework files! From ccb67f53f9415746aaddcef95105ebfd48b84ca1 Mon Sep 17 00:00:00 2001 From: visokoo Date: Wed, 9 Jan 2019 23:37:24 -0800 Subject: [PATCH 07/12] Adding python push ups - warmup 1 assignments --- students/visokoo/00-README.md | 25 +++++++++++++++++++ .../visokoo/lesson1_assignments/diff21.py | 21 ++++++++++++++++ .../visokoo/lesson1_assignments/makes10.py | 22 ++++++++++++++++ .../lesson1_assignments/near_hundred.py | 18 +++++++++++++ .../lesson1_assignments/parrot_trouble.py | 23 +++++++++++++++++ .../visokoo/lesson1_assignments/pos_neg.py | 24 ++++++++++++++++++ .../visokoo/lesson1_assignments/sum_double.py | 23 +++++++++++++++++ 7 files changed, 156 insertions(+) create mode 100644 students/visokoo/00-README.md create mode 100644 students/visokoo/lesson1_assignments/diff21.py create mode 100644 students/visokoo/lesson1_assignments/makes10.py create mode 100644 students/visokoo/lesson1_assignments/near_hundred.py create mode 100644 students/visokoo/lesson1_assignments/parrot_trouble.py create mode 100644 students/visokoo/lesson1_assignments/pos_neg.py create mode 100644 students/visokoo/lesson1_assignments/sum_double.py diff --git a/students/visokoo/00-README.md b/students/visokoo/00-README.md new file mode 100644 index 0000000..6d62924 --- /dev/null +++ b/students/visokoo/00-README.md @@ -0,0 +1,25 @@ +### About Me + +#### Intro +I started out in the tech world as a Helpdesk Specialist and was given +the opportunity move into the DevOps space about 2 years ago. It was a +rollercoaster ride going from full Windows to Linux but I loved every +moment of it. + +I've done some basic coding with ruby for some day to day tasks but I'm +really hoping to be able to do more with python like writing full-fledged +web apps or just something better than your standard script. + +In my freetime I generally enjoy: + +- Playing boardgames... +- Playing console/PC games... +- Thinking about solutions for work... +- Eating too much... +- Outdoor activities such as hiking, snowboarding, etc. + +### Goal + +I've done some basic coding with ruby for some day to day tasks but I'm +really hoping to be able to do more with python like writing full-fledged +web apps/cli tools or just something better than your standard script. diff --git a/students/visokoo/lesson1_assignments/diff21.py b/students/visokoo/lesson1_assignments/diff21.py new file mode 100644 index 0000000..6268765 --- /dev/null +++ b/students/visokoo/lesson1_assignments/diff21.py @@ -0,0 +1,21 @@ +''' +---------------------------------------------------- +Assignment: Python Push Ups - Warmup Part 1 - diff21.py +Author: visokoo | Created: 1/9/2019 +ChangeLog: 1/9/2019, Created file + +Given an int n, return the absolute difference between n and 21, +except return double the absolute difference if n is over 21. + +diff21(19) → 2 +diff21(10) → 11 +diff21(21) → 0 +---------------------------------------------------- + +''' + +def diff21(n): + if n > 21: + return abs(21-n)*2 + else: + return abs(21-n) diff --git a/students/visokoo/lesson1_assignments/makes10.py b/students/visokoo/lesson1_assignments/makes10.py new file mode 100644 index 0000000..8df7149 --- /dev/null +++ b/students/visokoo/lesson1_assignments/makes10.py @@ -0,0 +1,22 @@ +''' +---------------------------------------------------- +Assignment: Python Push Ups - Warmup Part 1 - makes10.py +Author: visokoo | Created: 1/9/2019 +ChangeLog: 1/9/2019, Created file + +Given 2 ints, a and b, return True if one if them is 10 or if their sum is 10. + +makes10(9, 10) → True +makes10(9, 9) → False +makes10(1, 9) → True +---------------------------------------------------- + +''' + +def makes10(a,b): + if a == 10 or b == 10: + return True + elif a + b == 10: + return True + else: + return False diff --git a/students/visokoo/lesson1_assignments/near_hundred.py b/students/visokoo/lesson1_assignments/near_hundred.py new file mode 100644 index 0000000..25a163c --- /dev/null +++ b/students/visokoo/lesson1_assignments/near_hundred.py @@ -0,0 +1,18 @@ +''' +---------------------------------------------------- +Assignment: Python Push Ups - Warmup Part 1 - near_hundred.py +Author: visokoo | Created: 1/9/2019 +ChangeLog: 1/9/2019, Created file + +Given an int n, return True if it is within 10 of 100 or 200. +Note: abs(num) computes the absolute value of a number. + +near_hundred(93) → True +near_hundred(90) → True +near_hundred(89) → False +---------------------------------------------------- + +''' + +def near_hundred(n): + return abs(100 - n) <= 10 or abs(200-n) <= 10 diff --git a/students/visokoo/lesson1_assignments/parrot_trouble.py b/students/visokoo/lesson1_assignments/parrot_trouble.py new file mode 100644 index 0000000..289ae41 --- /dev/null +++ b/students/visokoo/lesson1_assignments/parrot_trouble.py @@ -0,0 +1,23 @@ +''' +---------------------------------------------------- +Assignment: Python Push Ups - Warmup Part 1 - parrot_trouble.py +Author: visokoo | Created: 1/9/2019 +ChangeLog: 1/9/2019, Created file + +We have a loud talking parrot. The "hour" parameter is the current +hour time in the range 0..23. We are in trouble if the parrot is +talking and the hour is before 7 or after 20. Return True if we are +in trouble. + +parrot_trouble(True, 6) → True +parrot_trouble(True, 7) → False +parrot_trouble(False, 6) → False +---------------------------------------------------- + +''' + +def parrot_trouble(talking, hour): + if talking == True and (hour < 7 or hour > 20): + return True + else: + return False diff --git a/students/visokoo/lesson1_assignments/pos_neg.py b/students/visokoo/lesson1_assignments/pos_neg.py new file mode 100644 index 0000000..ac87fb6 --- /dev/null +++ b/students/visokoo/lesson1_assignments/pos_neg.py @@ -0,0 +1,24 @@ +''' +---------------------------------------------------- +Assignment: Python Push Ups - Warmup Part 1 - pos_neg.py +Author: visokoo | Created: 1/9/2019 +ChangeLog: 1/9/2019, Created file + + +Given 2 int values, return True if one is negative and one is +positive. Except if the parameter "negative" is True, then +return True only if both are negative. + +pos_neg(1, -1, False) → True +pos_neg(-1, 1, False) → True +pos_neg(-4, -5, True) → True +---------------------------------------------------- + +''' + +def pos_neg(a, b, negative): + if negative == True: + return (a < 0 and b < 0) + else: + return (a < 0 and b > 0) or (a > 0 and b < 0) + diff --git a/students/visokoo/lesson1_assignments/sum_double.py b/students/visokoo/lesson1_assignments/sum_double.py new file mode 100644 index 0000000..ee5e50b --- /dev/null +++ b/students/visokoo/lesson1_assignments/sum_double.py @@ -0,0 +1,23 @@ +''' +---------------------------------------------------- +Assignment: Python Push Ups - Warmup Part 1 - sum_double.py +Author: visokoo | Created: 1/9/2019 +ChangeLog: 1/9/2019, Created file + + +Given two int values, return their sum. Unless the two values +are the same, then return double their sum. + + +sum_double(1, 2) → 3 +sum_double(3, 2) → 5 +sum_double(2, 2) → 8 +---------------------------------------------------- + +''' + +def sum_double(a, b): + if a == b: + return ((a + b) * 2) + else: + return a + b From f499afd98fb111fddc81b9e4aaf74f1ae27845cd Mon Sep 17 00:00:00 2001 From: visokoo Date: Mon, 14 Jan 2019 12:41:08 -0800 Subject: [PATCH 08/12] Checking in lesson1 assignments --- .../visokoo/lesson1_assignments/break_me.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 students/visokoo/lesson1_assignments/break_me.py diff --git a/students/visokoo/lesson1_assignments/break_me.py b/students/visokoo/lesson1_assignments/break_me.py new file mode 100644 index 0000000..344d984 --- /dev/null +++ b/students/visokoo/lesson1_assignments/break_me.py @@ -0,0 +1,29 @@ +''' +---------------------------------------------------- +Assignment: Explore Errors +Author: visokoo | Created: 1/13/2019 +ChangeLog: 1/13/2019, Created file + +Create a script with four exceptions +---------------------------------------------------- + +''' + +def name_error(x): + print(y) + +#name_error(x) + +def value_error(x): + int(x) + print(x, "blah") + +#value_error("duh") + +def zero_division(x): + return x / 0 + +#zero_division(2) + +#def syntax_error(x) +# print(x) From ac9f996ab2304e62a1537c479898cf776482262c Mon Sep 17 00:00:00 2001 From: visokoo Date: Tue, 15 Jan 2019 18:34:26 -0800 Subject: [PATCH 09/12] removing old readme from /students/rroot --- students/RRoot/ReadMe.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 students/RRoot/ReadMe.txt diff --git a/students/RRoot/ReadMe.txt b/students/RRoot/ReadMe.txt deleted file mode 100644 index 9305c3e..0000000 --- a/students/RRoot/ReadMe.txt +++ /dev/null @@ -1 +0,0 @@ -This where I will put my homework files! From f3d8c7eebda9e9b6a246169870c7b60a6bf7ab93 Mon Sep 17 00:00:00 2001 From: visokoo Date: Wed, 16 Jan 2019 22:41:11 -0800 Subject: [PATCH 10/12] initial commit for python push ups warmup2 --- .../lesson2_assignments/front_times.py | 18 ++++++++++++++++ .../lesson2_assignments/string_bits.py | 21 +++++++++++++++++++ .../lesson2_assignments/string_times.py | 17 +++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 students/visokoo/lesson2_assignments/front_times.py create mode 100644 students/visokoo/lesson2_assignments/string_bits.py create mode 100644 students/visokoo/lesson2_assignments/string_times.py diff --git a/students/visokoo/lesson2_assignments/front_times.py b/students/visokoo/lesson2_assignments/front_times.py new file mode 100644 index 0000000..c2e90d5 --- /dev/null +++ b/students/visokoo/lesson2_assignments/front_times.py @@ -0,0 +1,18 @@ +''' +---------------------------------------------------- +Assignment: Python Push Ups - Warmup Part 2 - front_times.py +Author: visokoo | Created: 1/16/2019 +ChangeLog: 1/16/2019, Created file + +Given a string and a non-negative int n, we'll say that the front of the string is the first 3 chars, or whatever is there if the string is less than length 3. Return n copies of the front; + +front_times('Chocolate', 2) → 'ChoCho' +front_times('Chocolate', 3) → 'ChoChoCho' +front_times('Abc', 3) → 'AbcAbcAbc' +---------------------------------------------------- + +''' + +def front_times(str, n): + front = str[:3] + return front * n diff --git a/students/visokoo/lesson2_assignments/string_bits.py b/students/visokoo/lesson2_assignments/string_bits.py new file mode 100644 index 0000000..634a52f --- /dev/null +++ b/students/visokoo/lesson2_assignments/string_bits.py @@ -0,0 +1,21 @@ +''' +---------------------------------------------------- +Assignment: Python Push Ups - Warmup Part 2 - string_bits.py +Author: visokoo | Created: 1/16/2019 +ChangeLog: 1/16/2019, Created file + +Given a string, return a new string made of every other char starting with the first, so "Hello" yields "Hlo". + +string_bits('Hello') → 'Hlo' +string_bits('Hi') → 'H' +string_bits('Heeololeo') → 'Hello' + +---------------------------------------------------- + +''' + +def string_bits(str): + new_str = "" + for position in range(0, len(str), 2): + new_str += str[position] + return new_str diff --git a/students/visokoo/lesson2_assignments/string_times.py b/students/visokoo/lesson2_assignments/string_times.py new file mode 100644 index 0000000..afdc46e --- /dev/null +++ b/students/visokoo/lesson2_assignments/string_times.py @@ -0,0 +1,17 @@ +''' +---------------------------------------------------- +Assignment: Python Push Ups - Warmup Part 2 - string_times.py +Author: visokoo | Created: 1/16/2019 +ChangeLog: 1/16/2019, Created file + +Given a string and a non-negative int n, return a larger string that is n copies of the original string. + +string_times('Hi', 2) → 'HiHi' +string_times('Hi', 3) → 'HiHiHi' +string_times('Hi', 1) → 'Hi' +---------------------------------------------------- + +''' + +def string_times(str, n): + return str * n From d5afd3a450674321ca11c3876204251709eb1bf5 Mon Sep 17 00:00:00 2001 From: visokoo Date: Sun, 20 Jan 2019 15:59:26 -0800 Subject: [PATCH 11/12] Adding in grid_printer.py, series.py, and fizz_buzz.py --- .../visokoo/lesson2_assignments/fizz_buzz.py | 24 ++++++ .../lesson2_assignments/grid_printer.py | 53 ++++++++++++ .../visokoo/lesson2_assignments/series.py | 86 +++++++++++++++++++ 3 files changed, 163 insertions(+) create mode 100644 students/visokoo/lesson2_assignments/fizz_buzz.py create mode 100644 students/visokoo/lesson2_assignments/grid_printer.py create mode 100644 students/visokoo/lesson2_assignments/series.py diff --git a/students/visokoo/lesson2_assignments/fizz_buzz.py b/students/visokoo/lesson2_assignments/fizz_buzz.py new file mode 100644 index 0000000..e6afa64 --- /dev/null +++ b/students/visokoo/lesson2_assignments/fizz_buzz.py @@ -0,0 +1,24 @@ +''' +---------------------------------------------------- +Assignment: fizz_buzz.py +Author: visokoo | Created: 1/20/2019 +ChangeLog: 1/20/2019, Created file + +Write a program that prints the numbers from 1 - 100 inclusive. +For multiples of three, print "Fizz", multiples of five, print "Buzz." +Numbers that are multiples of both, print "FizzBuzz." +''' + +def fizz_buzz(n): + for num in range(n): + if num % 5 == 0 and num % 10 == 0: + msg = "FizzBuzz" + elif num % 5 == 0: + msg = "Fizz" + elif num % 10 == 0: + msg = "Buzz" + else: + msg = num + print(msg) + +fizz_buzz(101) \ No newline at end of file diff --git a/students/visokoo/lesson2_assignments/grid_printer.py b/students/visokoo/lesson2_assignments/grid_printer.py new file mode 100644 index 0000000..5c5bc1a --- /dev/null +++ b/students/visokoo/lesson2_assignments/grid_printer.py @@ -0,0 +1,53 @@ +''' +---------------------------------------------------- +Assignment: grid_printer.py +Author: visokoo | Created: 1/16/2019 +ChangeLog: 1/16/2019, Created file + +Write a function that draws a grid like the following: ++ - - - - + - - - - + +| | | +| | | +| | | +| | | ++ - - - - + - - - - + +| | | +| | | +| | | +| | | ++ - - - - + - - - - + +---------------------------------------------------- +''' + +def borders(n): + return " + " + " - " * n + +def pillars(n): + return " | " + " " * (n * 3) + +def grid_printer(n): + print(borders(n) * 2, "+") + for i in range(n): + print(pillars(n) * 2, "|", sep=" ") + print(borders(n) * 2, "+") + for i in range(n): + print(pillars(n) * 2, "|", sep=" ") + print(borders(n) * 2, "+") + +def fancy_grid_printer(table_size, grid_size): + print(borders(grid_size) * table_size, "+") + for i in range(table_size): + for j in range(grid_size): + print(pillars(grid_size) * table_size, "|", sep=" ") + print(borders(grid_size) * table_size, "+") + +while True: + prompt = input("Standard 2x2 table or fancy table?" + "\n" + "Options: standard/fancy/exit ") + if prompt.lower() == "standard": + size = input("Pick a size for your table, larger the number, larger the table. 1 - infinity ") + grid_printer(int(size)) + elif prompt.lower() == "fancy": + total_table_size = input("Number of rows and columns? 1 - infinity ") + width = input("Width of each grid? 1 - infinity ") + fancy_grid_printer(int(total_table_size), int(width)) + else: break diff --git a/students/visokoo/lesson2_assignments/series.py b/students/visokoo/lesson2_assignments/series.py new file mode 100644 index 0000000..c607d09 --- /dev/null +++ b/students/visokoo/lesson2_assignments/series.py @@ -0,0 +1,86 @@ +''' +---------------------------------------------------- +Assignment: series.py +Author: visokoo | Created: 1/17/2019 +ChangeLog: 1/17/2019, Created file + +Write 3 functions: fibonacci, lucas, and sum_series and some tests +for the functionality. + +Fibonacci: +The Fibonacci Series is a numeric series starting with the integers 0 and 1. +In this series, the next integer is determined by summing the previous two. +This gives us: +0, 1, 1, 2, 3, 5, 8, 13, ... + +Lucas: +The Lucas Numbers are a related series of integers that start with the values +2 and 1 rather than 0 and 1. The resulting series looks like this: +2, 1, 3, 4, 7, 11, 18, 29, ... + +sum_series: +Create a function with one required parameter and two optional parameters. The required +parameter will determine which element in the series to print. The two optional parameters +will have default values of 0 and 1 and will determine the first two values for the series +to be produced. +''' + +def fibonacci(n): + ''' + fib(n) = fib(n-2) + fib(n-1) + Given the value n, call the sum_series function with that value + and return the fibonacci sequence at the nth index + ''' + return sum_series(n) + +def lucas(n): + ''' + Formula is the same as fib, but starting values are 2 and 1 respectively + Given the value n, call the sum_series function with that value and + return the lucas sequence at the nth index + ''' + return sum_series(n, v1=2, v2=0) + +def sum_series(n, v1=0, v2=1): + ''' + compute the nth value of a summation series. + + :param v1=0: value of zeroth element in the series + :param v2=1: value of first element in the series + + This function should generalize the fibonacci() and the lucas(), + so that this function works for any first two numbers for a sum series. + Once generalized that way, sum_series(n, 0, 1) should be equivalent to + fibonacci(n). And sum_series(n, 2, 1) should be equivalent to lucas(n). + ''' + if v1 is 2: + if n == 0: + return 2 + elif n == 1: + return 1 + else: + return sum_series(n - 2, v1=v1, v2=v2) + sum_series(n - 1, v1=v1, v2=v2) + else: + if n > 1: + return sum_series(n - 2) + sum_series(n - 1) + return n + +if __name__ == "__main__": + # run some tests to make sure the fibonacci() is returning expected values. + assert fibonacci(0) == 0 + assert fibonacci(1) == 1 + assert fibonacci(2) == 1 + assert fibonacci(3) == 2 + assert fibonacci(4) == 3 + assert fibonacci(5) == 5 + assert fibonacci(6) == 8 + assert fibonacci(7) == 13 + # run some tests to make sure the lucas() is returning expected values. + assert lucas(0) == 2 + assert lucas(1) == 1 + assert lucas(4) == 7 + # make sure sum_series outputs match fibonacci() and lucas() outputs. + assert sum_series(5) == fibonacci(5) + assert sum_series(5, 2, 1) == lucas(5) + + print("Tests passed.") \ No newline at end of file From 5527af6ad32671db6b3182037765d3400630b03b Mon Sep 17 00:00:00 2001 From: visokoo Date: Sun, 20 Jan 2019 16:39:42 -0800 Subject: [PATCH 12/12] mixed up numbers, corrected to 3 and 5 --- students/visokoo/lesson2_assignments/fizz_buzz.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/students/visokoo/lesson2_assignments/fizz_buzz.py b/students/visokoo/lesson2_assignments/fizz_buzz.py index e6afa64..74c4888 100644 --- a/students/visokoo/lesson2_assignments/fizz_buzz.py +++ b/students/visokoo/lesson2_assignments/fizz_buzz.py @@ -11,11 +11,11 @@ def fizz_buzz(n): for num in range(n): - if num % 5 == 0 and num % 10 == 0: + if num % 3 == 0 and num % 5 == 0: msg = "FizzBuzz" - elif num % 5 == 0: + elif num % 3 == 0: msg = "Fizz" - elif num % 10 == 0: + elif num % 5 == 0: msg = "Buzz" else: msg = num