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/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) 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 diff --git a/students/visokoo/lesson2_assignments/fizz_buzz.py b/students/visokoo/lesson2_assignments/fizz_buzz.py new file mode 100644 index 0000000..74c4888 --- /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 % 3 == 0 and num % 5 == 0: + msg = "FizzBuzz" + elif num % 3 == 0: + msg = "Fizz" + elif num % 5 == 0: + msg = "Buzz" + else: + msg = num + print(msg) + +fizz_buzz(101) \ No newline at end of file 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/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 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