From a51b52a81c95aaa363b31b39f83d12c7a96d3eff Mon Sep 17 00:00:00 2001 From: Robert Kesterson Date: Sun, 27 Jan 2019 19:52:26 -0800 Subject: [PATCH 01/30] Adding in content from previous week --- students/robert_kesterson/.idea/encodings.xml | 4 + students/robert_kesterson/.idea/misc.xml | 4 + students/robert_kesterson/.idea/modules.xml | 8 ++ .../.idea/robert_kesterson.iml | 13 +++ students/robert_kesterson/.idea/vcs.xml | 6 ++ students/robert_kesterson/.idea/workspace.xml | 9 ++ .../In_class_exercises/Lab_3_1.py | 7 ++ .../list_1_first_last6.py | 9 ++ .../list_1_same_first_last.py | 9 ++ .../logic_1_cigar_party.py | 11 +++ .../logic_1_date_fashion.py | 13 +++ .../string_1_hello_name.py | 7 ++ .../string_1_make_abba.py | 7 ++ .../warmup_1_monkey_trouble.py | 11 +++ .../warmup_1_sleep_in.py | 9 ++ .../lesson_02_fibonacci_series.py | 86 +++++++++++++++++++ .../lesson_02_exercise_fizz_buzz.py | 25 ++++++ .../lesson_02_exercise_grid_printer.py | 71 +++++++++++++++ .../list_2_big_diff.py | 14 +++ .../list_2_count_evens.py | 12 +++ .../logic_2_lone_sum.py | 15 ++++ .../logic_2_lucky_sum.py | 15 ++++ .../string_2_count_hi.py | 12 +++ .../string_2_double_char.py | 9 ++ .../warmup_2_front_times.py | 6 ++ .../warmup_2_string_times.py | 6 ++ 26 files changed, 398 insertions(+) create mode 100644 students/robert_kesterson/.idea/encodings.xml create mode 100644 students/robert_kesterson/.idea/misc.xml create mode 100644 students/robert_kesterson/.idea/modules.xml create mode 100644 students/robert_kesterson/.idea/robert_kesterson.iml create mode 100644 students/robert_kesterson/.idea/vcs.xml create mode 100644 students/robert_kesterson/.idea/workspace.xml create mode 100644 students/robert_kesterson/In_class_exercises/Lab_3_1.py create mode 100644 students/robert_kesterson/lesson_01_python_pushups_1_of_2/list_1_first_last6.py create mode 100644 students/robert_kesterson/lesson_01_python_pushups_1_of_2/list_1_same_first_last.py create mode 100644 students/robert_kesterson/lesson_01_python_pushups_1_of_2/logic_1_cigar_party.py create mode 100644 students/robert_kesterson/lesson_01_python_pushups_1_of_2/logic_1_date_fashion.py create mode 100644 students/robert_kesterson/lesson_01_python_pushups_1_of_2/string_1_hello_name.py create mode 100644 students/robert_kesterson/lesson_01_python_pushups_1_of_2/string_1_make_abba.py create mode 100644 students/robert_kesterson/lesson_01_python_pushups_1_of_2/warmup_1_monkey_trouble.py create mode 100644 students/robert_kesterson/lesson_01_python_pushups_1_of_2/warmup_1_sleep_in.py create mode 100644 students/robert_kesterson/lesson_02_exercise_fibonacci_series/lesson_02_fibonacci_series.py create mode 100644 students/robert_kesterson/lesson_02_exercise_fizz_buzz/lesson_02_exercise_fizz_buzz.py create mode 100644 students/robert_kesterson/lesson_02_exercise_grid_printer/lesson_02_exercise_grid_printer.py create mode 100644 students/robert_kesterson/lesson_02_python_pushups_2_of_2/list_2_big_diff.py create mode 100644 students/robert_kesterson/lesson_02_python_pushups_2_of_2/list_2_count_evens.py create mode 100644 students/robert_kesterson/lesson_02_python_pushups_2_of_2/logic_2_lone_sum.py create mode 100644 students/robert_kesterson/lesson_02_python_pushups_2_of_2/logic_2_lucky_sum.py create mode 100644 students/robert_kesterson/lesson_02_python_pushups_2_of_2/string_2_count_hi.py create mode 100644 students/robert_kesterson/lesson_02_python_pushups_2_of_2/string_2_double_char.py create mode 100644 students/robert_kesterson/lesson_02_python_pushups_2_of_2/warmup_2_front_times.py create mode 100644 students/robert_kesterson/lesson_02_python_pushups_2_of_2/warmup_2_string_times.py diff --git a/students/robert_kesterson/.idea/encodings.xml b/students/robert_kesterson/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/students/robert_kesterson/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/students/robert_kesterson/.idea/misc.xml b/students/robert_kesterson/.idea/misc.xml new file mode 100644 index 0000000..3b754fd --- /dev/null +++ b/students/robert_kesterson/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/students/robert_kesterson/.idea/modules.xml b/students/robert_kesterson/.idea/modules.xml new file mode 100644 index 0000000..15854c3 --- /dev/null +++ b/students/robert_kesterson/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/students/robert_kesterson/.idea/robert_kesterson.iml b/students/robert_kesterson/.idea/robert_kesterson.iml new file mode 100644 index 0000000..85c7612 --- /dev/null +++ b/students/robert_kesterson/.idea/robert_kesterson.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/students/robert_kesterson/.idea/vcs.xml b/students/robert_kesterson/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/students/robert_kesterson/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/students/robert_kesterson/.idea/workspace.xml b/students/robert_kesterson/.idea/workspace.xml new file mode 100644 index 0000000..19771ef --- /dev/null +++ b/students/robert_kesterson/.idea/workspace.xml @@ -0,0 +1,9 @@ + + + + + \ No newline at end of file diff --git a/students/robert_kesterson/In_class_exercises/Lab_3_1.py b/students/robert_kesterson/In_class_exercises/Lab_3_1.py new file mode 100644 index 0000000..0c6e90f --- /dev/null +++ b/students/robert_kesterson/In_class_exercises/Lab_3_1.py @@ -0,0 +1,7 @@ +tplData = (1, "Bob Smith", "555-4335", True) + +i = 0 +while i < 4: + print(tplData[i]) + i += 1 + diff --git a/students/robert_kesterson/lesson_01_python_pushups_1_of_2/list_1_first_last6.py b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/list_1_first_last6.py new file mode 100644 index 0000000..5e5d2c5 --- /dev/null +++ b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/list_1_first_last6.py @@ -0,0 +1,9 @@ +# Define the function +def first_last6(nums): + if nums[0] == 6 or nums[len(nums) - 1] == 6: + return True + else: + return False + +# Call the function +first_last6(10, 8) diff --git a/students/robert_kesterson/lesson_01_python_pushups_1_of_2/list_1_same_first_last.py b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/list_1_same_first_last.py new file mode 100644 index 0000000..4a0755d --- /dev/null +++ b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/list_1_same_first_last.py @@ -0,0 +1,9 @@ +# Define the function +def same_first_last(nums): + if len(nums) >= 1 and nums[0] == nums[len(nums) - 1]: + return True + else: + return False + +# Call the function +same_first_last([10]) diff --git a/students/robert_kesterson/lesson_01_python_pushups_1_of_2/logic_1_cigar_party.py b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/logic_1_cigar_party.py new file mode 100644 index 0000000..e9bdfe9 --- /dev/null +++ b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/logic_1_cigar_party.py @@ -0,0 +1,11 @@ +# Define the function +def cigar_party(cigars, is_weekend): + if not is_weekend and 40 <= cigars <= 60: + return True + if is_weekend and 40 <= cigars: + return True + else: + return False + +# Call the function +cigar_party(35, False) diff --git a/students/robert_kesterson/lesson_01_python_pushups_1_of_2/logic_1_date_fashion.py b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/logic_1_date_fashion.py new file mode 100644 index 0000000..c92851d --- /dev/null +++ b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/logic_1_date_fashion.py @@ -0,0 +1,13 @@ +# Define the function +def date_fashion(you, date): + if you >= 8 and date >= 3: + return 2 + elif you >= 3 and date >= 8: + return 2 + elif you <= 2 or date <= 2: + return 0 + else: + return 1 + +# Call the function +date_fashion(2, 9) diff --git a/students/robert_kesterson/lesson_01_python_pushups_1_of_2/string_1_hello_name.py b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/string_1_hello_name.py new file mode 100644 index 0000000..9077287 --- /dev/null +++ b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/string_1_hello_name.py @@ -0,0 +1,7 @@ +# Define the function +def hello_name(name): + greetingString = "Hello " + name + "!" + return greetingString + +# Call the function +hello_name('Alice') diff --git a/students/robert_kesterson/lesson_01_python_pushups_1_of_2/string_1_make_abba.py b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/string_1_make_abba.py new file mode 100644 index 0000000..09f06d8 --- /dev/null +++ b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/string_1_make_abba.py @@ -0,0 +1,7 @@ +# Define the function +def make_abba(a, b): + abba_string = a + b + b + a + return abba_string + +# Call the function +make_abba('hello','Captain') diff --git a/students/robert_kesterson/lesson_01_python_pushups_1_of_2/warmup_1_monkey_trouble.py b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/warmup_1_monkey_trouble.py new file mode 100644 index 0000000..b3aac06 --- /dev/null +++ b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/warmup_1_monkey_trouble.py @@ -0,0 +1,11 @@ +# Define the function +def monkey_trouble(a_smile, b_smile): + if a_smile and b_smile: + return True + elif not a_smile and not b_smile: + return True + else: + return False + +# Call the function +monkey_trouble(True, True) diff --git a/students/robert_kesterson/lesson_01_python_pushups_1_of_2/warmup_1_sleep_in.py b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/warmup_1_sleep_in.py new file mode 100644 index 0000000..161e925 --- /dev/null +++ b/students/robert_kesterson/lesson_01_python_pushups_1_of_2/warmup_1_sleep_in.py @@ -0,0 +1,9 @@ +# Define the function +def sleep_in(weekday, vacation): + if vacation or weekday is False: + return True + else: + return False + +# Call the function +sleep_in(False, True) diff --git a/students/robert_kesterson/lesson_02_exercise_fibonacci_series/lesson_02_fibonacci_series.py b/students/robert_kesterson/lesson_02_exercise_fibonacci_series/lesson_02_fibonacci_series.py new file mode 100644 index 0000000..a17597d --- /dev/null +++ b/students/robert_kesterson/lesson_02_exercise_fibonacci_series/lesson_02_fibonacci_series.py @@ -0,0 +1,86 @@ +# -------------------------------------------- # +# Title: Lesson 02 Exercise: Fibonacci Series +# Desc: Holds functions (and asset tests) related to the Fibonacci and Lucas series +# Change log: (who, when, what) +# RKesterson, 2019-01-22, Created file +# RKestesron, 2019-01-22, Stubbed out methods / parts +# RKesterson, 2019-01-22, Completed step one (fibonacci function) +# RKesterson, 2019-01-22, Completed step two (lucas function) +# RKesterson, 2019-01-22, Completed step three (sum_series function) +# RKesterson, 2019-01-22, Completed testing using assert statements +# ---------------------------------------------- # + +# Define the function +def fibonacci(n): + """ compute the nth Fibonacci number """ + if n == 0: + return 0 + elif n == 1: + return 1 + else: + return fibonacci(n - 2) + fibonacci(n - 1) + pass + +# Call the function +#print(fibonacci(7)) + +# Define the function +def lucas(n): + """ compute the nth Lucas number """ + if n == 0: + return 2 + elif n == 1: + return 1 + else: + return lucas(n - 2) + lucas(n - 1) + pass + +# Call the function +#print(lucas(5)) + +# Define the function +def sum_series(n, m = 0, o = 1): + """ + compute the nth value of a summation series. + + :param n0=0: value of zeroth element in the series + :param n1=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 n == 0: + return m + elif n == 1: + return o + else: + return sum_series(n - 2, m, o) + sum_series(n - 1, m, o) + pass + +# Call the function +#print(sum_series(4, 2, 1)) + +if __name__ == "__main__": + # run some tests + 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 + + assert lucas(0) == 2 + assert lucas(1) == 1 + + assert lucas(4) == 7 + + assert sum_series(5) == fibonacci(5) + + # test if sum_series matched lucas + assert sum_series(5, 2, 1) == lucas(5) + + print("tests passed") \ No newline at end of file diff --git a/students/robert_kesterson/lesson_02_exercise_fizz_buzz/lesson_02_exercise_fizz_buzz.py b/students/robert_kesterson/lesson_02_exercise_fizz_buzz/lesson_02_exercise_fizz_buzz.py new file mode 100644 index 0000000..c78b9f3 --- /dev/null +++ b/students/robert_kesterson/lesson_02_exercise_fizz_buzz/lesson_02_exercise_fizz_buzz.py @@ -0,0 +1,25 @@ +# -------------------------------------------- # +# Title: Lesson 02 Exercise: Fizz Buzz +# Desc: The classic fizz buzz interview question, spoken of in song and story +# Change log: (who, when, what) +# RKesterson, 2019-01-22, Created file +# RKestesron, 2019-01-22, Stubbed out methods / parts +# RKesterson, 2019-01-22, Completed program +# ---------------------------------------------- # + +# Define the function +def fizzBuzz(): + i = 1 + while i < 101: + if (i % 3 == 0 and i % 5 == 0): + print('FizzBuzz') + elif (i % 3 == 0 and i % 5 != 0): + print('Fizz') + elif (i % 3 != 0 and i % 5 == 0): + print('Buzz') + else: + print(i) + i += 1 + +# Call the function +fizzBuzz() \ No newline at end of file diff --git a/students/robert_kesterson/lesson_02_exercise_grid_printer/lesson_02_exercise_grid_printer.py b/students/robert_kesterson/lesson_02_exercise_grid_printer/lesson_02_exercise_grid_printer.py new file mode 100644 index 0000000..84925cb --- /dev/null +++ b/students/robert_kesterson/lesson_02_exercise_grid_printer/lesson_02_exercise_grid_printer.py @@ -0,0 +1,71 @@ +# -------------------------------------------- # +# Title: Lesson 02 Exercise: Grid Printer +# Desc: Prints out grids of different sizes using different functions +# Change log: (who, when, what) +# RKesterson, 2019-01-22, Created file +# RKestesron, 2019-01-22, Stubbed out methods / parts +# RKesterson, 2019-01-22, Completed part one +# RKesterson, 2019-01-22, Completed part two +# RKesterson, 2019-01-22, Completed part three +# ---------------------------------------------- # + +# Part one +levelOne = '+ - - - - + - - - - +' +levelTwo = '| | |' + +print(levelOne) +print(levelTwo) +print(levelTwo) +print(levelTwo) +print(levelTwo) +print(levelOne) +print(levelTwo) +print(levelTwo) +print(levelTwo) +print(levelTwo) +print(levelOne) + +# Part two +# Define the function +def print_grid(n): + dashCount = int(n / 2) + post = '+ ' + column = '| ' + floor = '- ' + openFloor = ' ' + levelOne = post + floor * dashCount + post + floor * dashCount + post + levelTwo = column + openFloor * dashCount + column + openFloor * dashCount + column + print(levelOne) + i = 0 + while i < dashCount: + print(levelTwo) + i += 1 + print(levelOne) + i = 0 + while i < dashCount: + print(levelTwo) + i += 1 + print(levelOne) + +# Call the function +print_grid(15) + +# Part three +# Define the function +def print_grid2(n, m): + unitTop = '+ ' + '- ' * m + unitTopFull = unitTop * n + '+' + unitBottom = '| ' + ' ' * m + unitBottomFull = unitBottom * n + '|' + i = 0 + while i < n: + print(unitTopFull) + j = 0 + while j < m: + print(unitBottomFull) + j += 1 + i += 1 + print(unitTopFull) + +# Call the function +print_grid2(5, 3) \ No newline at end of file diff --git a/students/robert_kesterson/lesson_02_python_pushups_2_of_2/list_2_big_diff.py b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/list_2_big_diff.py new file mode 100644 index 0000000..326e6b8 --- /dev/null +++ b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/list_2_big_diff.py @@ -0,0 +1,14 @@ +# Define the function +def big_diff(nums): + largestObserved = nums[0] + smallestObserved = nums[0] + iCounter = 1 + while iCounter < len(nums): + smallestObserved = min(smallestObserved, nums[iCounter]) + largestObserved = max(largestObserved, nums[iCounter]) + iCounter += 1 + difference = largestObserved - smallestObserved + return difference + +# Call the function +big_diff([10, 2]) \ No newline at end of file diff --git a/students/robert_kesterson/lesson_02_python_pushups_2_of_2/list_2_count_evens.py b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/list_2_count_evens.py new file mode 100644 index 0000000..3167143 --- /dev/null +++ b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/list_2_count_evens.py @@ -0,0 +1,12 @@ +# Define the function +def count_evens(nums): + evenCount = 0 + indexI = 0 + while indexI < len(nums): + if nums[indexI] % 2 == 0: + evenCount += 1 + indexI += 1 + return evenCount + +# Call the function +count_evens([2, 7, 1, 4]) \ No newline at end of file diff --git a/students/robert_kesterson/lesson_02_python_pushups_2_of_2/logic_2_lone_sum.py b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/logic_2_lone_sum.py new file mode 100644 index 0000000..8f57685 --- /dev/null +++ b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/logic_2_lone_sum.py @@ -0,0 +1,15 @@ +# Define the function +def lone_sum(a, b, c): + sum = 0 + if a != b and a != c and b !=c: + sum = a + b + c + elif a != b and b == c: + sum = a + elif a == b and b != c: + sum = c + elif a == c and b != c: + sum = b + return sum + +# Call the function +lone_sum(2, 3, 5) \ No newline at end of file diff --git a/students/robert_kesterson/lesson_02_python_pushups_2_of_2/logic_2_lucky_sum.py b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/logic_2_lucky_sum.py new file mode 100644 index 0000000..10153ac --- /dev/null +++ b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/logic_2_lucky_sum.py @@ -0,0 +1,15 @@ +# Define function +def lucky_sum(a, b, c): + sum = 0 + if a == 13: + sum = 0 + elif b == 13: + sum = a + elif c == 13: + sum = a + b + else: + sum = a + b + c + return sum + +# Call function +lucky_sum(2, 3, 5) \ No newline at end of file diff --git a/students/robert_kesterson/lesson_02_python_pushups_2_of_2/string_2_count_hi.py b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/string_2_count_hi.py new file mode 100644 index 0000000..791cbce --- /dev/null +++ b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/string_2_count_hi.py @@ -0,0 +1,12 @@ +# Define the function +def count_hi(str): + count = 0 + iCounter = 0 + while (iCounter < len(str)): + if str[iCounter:iCounter + 2] == 'hi': + count += 1 + iCounter += 1 + return count + +# Call the function +count_hi('hihellofromMadagascarhi') \ No newline at end of file diff --git a/students/robert_kesterson/lesson_02_python_pushups_2_of_2/string_2_double_char.py b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/string_2_double_char.py new file mode 100644 index 0000000..186c1b5 --- /dev/null +++ b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/string_2_double_char.py @@ -0,0 +1,9 @@ +# Define the function +def double_char(str): + result = '' + for i in range(len(str)): + result = result + str[i] * 2 + return result + +# Call the function +double_char('cow-a-bunga') \ No newline at end of file diff --git a/students/robert_kesterson/lesson_02_python_pushups_2_of_2/warmup_2_front_times.py b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/warmup_2_front_times.py new file mode 100644 index 0000000..e44b5af --- /dev/null +++ b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/warmup_2_front_times.py @@ -0,0 +1,6 @@ +# Define the function +def front_times(str, n): + return str[0:3] * n + +# Call the function +front_times('ello', 4) \ No newline at end of file diff --git a/students/robert_kesterson/lesson_02_python_pushups_2_of_2/warmup_2_string_times.py b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/warmup_2_string_times.py new file mode 100644 index 0000000..dd62cc5 --- /dev/null +++ b/students/robert_kesterson/lesson_02_python_pushups_2_of_2/warmup_2_string_times.py @@ -0,0 +1,6 @@ +# Ddefine the function +def string_times(str, n): + return str * n + +# Call the function +string_times('argghh says Charlie Brown', 3) \ No newline at end of file From 7b507c8f715b5743f67580cbd5f8835f6feb1f53 Mon Sep 17 00:00:00 2001 From: Robert Kesterson Date: Sun, 27 Jan 2019 20:13:24 -0800 Subject: [PATCH 02/30] checking in stubs for list_lab --- .../robert_kesterson/session03/list_lab.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 students/robert_kesterson/session03/list_lab.py diff --git a/students/robert_kesterson/session03/list_lab.py b/students/robert_kesterson/session03/list_lab.py new file mode 100644 index 0000000..5ce7337 --- /dev/null +++ b/students/robert_kesterson/session03/list_lab.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +# -------------------------------------------- # +# Title: Lesson 03 Exercise: List Lab +# Desc: This is a lab where we will learn about list manipulation +# Change log: (who, when, what) +# RKesterson, 2019-01-27, Created file +# RKestesron, 2019-01-27, Stubbed out methods / parts +# RKesterson, 2019-01-XX, Completed series one +# RKesterson, 2019-01-XX, Completed series two +# RKesterson, 2019-01-XX, Completed series three +# RKesterson, 2019-01-XX, Completed series four +# ---------------------------------------------- # + +# Series one + +# Series two + +# Series three + +# Series four \ No newline at end of file From 19382dd8448db3184af6fc7f9c543a1103a76589 Mon Sep 17 00:00:00 2001 From: Robert Kesterson Date: Sun, 27 Jan 2019 21:00:54 -0800 Subject: [PATCH 03/30] done with series one --- students/robert_kesterson/session03/list_lab.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/students/robert_kesterson/session03/list_lab.py b/students/robert_kesterson/session03/list_lab.py index 5ce7337..3c8becf 100644 --- a/students/robert_kesterson/session03/list_lab.py +++ b/students/robert_kesterson/session03/list_lab.py @@ -6,13 +6,25 @@ # Change log: (who, when, what) # RKesterson, 2019-01-27, Created file # RKestesron, 2019-01-27, Stubbed out methods / parts -# RKesterson, 2019-01-XX, Completed series one -# RKesterson, 2019-01-XX, Completed series two +# RKesterson, 2019-01-27, Completed series one (question about this to be posted to forum) +# RKesterson, 2019-01-XX, Completed series two # RKesterson, 2019-01-XX, Completed series three # RKesterson, 2019-01-XX, Completed series four # ---------------------------------------------- # # Series one +listSeriesOne = ["Apples", "Pears", "Oranges", "Peaches"] +print(listSeriesOne) +response = input("Choose a fruit to add to the list: ") +listSeriesOne.append(response) +print(listSeriesOne) +response = input("Select a fruit by number: ") +fruitSelection = int(response) +print("Fruit number " + response + " - " + listSeriesOne[fruitSelection - 1]) +# listSeriesOne[0] +#print(listSeriesOne) +listSeriesOne.insert(0, "Strawberries") +print(listSeriesOne) # Series two From 31d088ee8b24a84d56f5d55789fc1a54123f4ed4 Mon Sep 17 00:00:00 2001 From: Robert Kesterson Date: Mon, 28 Jan 2019 19:35:48 -0800 Subject: [PATCH 04/30] Done with list_lab.py --- .../robert_kesterson/session03/list_lab.py | 41 +++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/students/robert_kesterson/session03/list_lab.py b/students/robert_kesterson/session03/list_lab.py index 3c8becf..fb1ce94 100644 --- a/students/robert_kesterson/session03/list_lab.py +++ b/students/robert_kesterson/session03/list_lab.py @@ -6,10 +6,10 @@ # Change log: (who, when, what) # RKesterson, 2019-01-27, Created file # RKestesron, 2019-01-27, Stubbed out methods / parts -# RKesterson, 2019-01-27, Completed series one (question about this to be posted to forum) -# RKesterson, 2019-01-XX, Completed series two -# RKesterson, 2019-01-XX, Completed series three -# RKesterson, 2019-01-XX, Completed series four +# RKesterson, 2019-01-28, Completed series one (question about this to be posted to forum) +# RKesterson, 2019-01-28, Completed series two +# RKesterson, 2019-01-28, Completed series three +# RKesterson, 2019-01-28, Completed series four # ---------------------------------------------- # # Series one @@ -21,13 +21,40 @@ response = input("Select a fruit by number: ") fruitSelection = int(response) print("Fruit number " + response + " - " + listSeriesOne[fruitSelection - 1]) -# listSeriesOne[0] -#print(listSeriesOne) +listSeriesTwo = ["eggplant"] +listSeriesOne = listSeriesTwo + listSeriesOne +print(listSeriesOne) listSeriesOne.insert(0, "Strawberries") print(listSeriesOne) # Series two +print(listSeriesOne) +listSeriesOne = listSeriesOne[:-1] +print(listSeriesOne) +response = input("Choose a fruit to delete from the list: ") +listSeriesOne.remove(response) +print(listSeriesOne) # Series three +for fruit in listSeriesOne: + response = input("Do you like " + fruit.lower() + " ? (yes / no) ") + if response == "no": + listSeriesOne.remove(fruit) + while response != 'yes' and response != "no": + response = input("Answer must be \"yes\" or \"no\". Do you like " + fruit.lower() + " ? (yes / no) ") +print(listSeriesOne) + +# Series four +def recursiveReverse(input): + if len(input) == 0: + return input + else: + return recursiveReverse(input[1:]) + input[0] -# Series four \ No newline at end of file +listSeriesFour = [] +for fruit in listSeriesOne: + listSeriesFour.append(recursiveReverse(fruit)) + +listSeriesOne = listSeriesOne[:-1] +print(listSeriesOne) +print(listSeriesFour) \ No newline at end of file From 17ac6a054f1fd272bcf6e003fd9b6964b546439d Mon Sep 17 00:00:00 2001 From: Robert Kesterson Date: Tue, 29 Jan 2019 03:36:43 -0800 Subject: [PATCH 05/30] done with string formatting lab --- .../session03/strformatlab.py | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 students/robert_kesterson/session03/strformatlab.py diff --git a/students/robert_kesterson/session03/strformatlab.py b/students/robert_kesterson/session03/strformatlab.py new file mode 100644 index 0000000..a2e68ed --- /dev/null +++ b/students/robert_kesterson/session03/strformatlab.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 + +# -------------------------------------------- # +# Title: Lesson 03 Exercise: List Lab +# Desc: This is a lab where we will learn about list manipulation +# Change log: (who, when, what) +# RKesterson, 2019-01-28, Created file +# RKestesron, 2019-01-28, Stubbed out methods / parts +# RKesterson, 2019-01-28, Completed task one +# RKesterson, 2019-01-28, Started task two +# RKesterson, 2019-01-28, Completed task three +# RKesterson, 2019-01-28, Completed task four +# RKesterson, 2019-01-28, Completed task five +# RKesterson, 2019-01-28, Completed task six +# ---------------------------------------------- # + +# Task one +''' +Method definition erroneously added below +def formatFunction(x): + filenumber = x[0] + filename = "" + if filenumber < 10: + filename = "file00{:d}".format(filenumber) + elif 10 <= filenumber < 100: + filename = "file0{:d}".format(filenumber) + else: + filename = "file{:d}".format(filenumber) + print(filename) + firstnumber = '%.2f' % x[1] + print(firstnumber) + secondnumber = "{:.2e}".format(x[2]) + print(secondnumber) + thirdnumber = "{:.2e}".format(x[3]) + print(thirdnumber) +''' +tupleOne = (2, 123.4567, 10000, 12345.67) +formatString = "file00{:d} {:.2f} {:.2e} {:.2e}".format(tupleOne[0], tupleOne[1], tupleOne[2], tupleOne[3]) +#print(formatString) + +# Task two +# Will return + +# Task three +def formatmethod(input_tuple): + setlength = len(t) + # return ", ".join(["{}"] * setlength).format(*input_tuple) + # return "the {} elements are: ".format(setlength) + return ("the {} elements are: " + ", ".join(["{}"] * setlength)).format(setlength, *input_tuple) + +t = (1, 2, 3, 4, 5, 7) +#print(formatmethod(t)) + +# Task four +tupleFour = (4, 30, 2017, 2, 27) +stringFour = ("0{} {} {} 0{} {}").format(tupleFour[3], tupleFour[4], tupleFour[2], tupleFour[0], tupleFour[1]) +#print(stringFour) + +# '02 27 2017 04 30' + +# Task five +tupleFive = ['oranges', 1.3, 'lemons', 1.1] +firstFruit = tupleFive[0] +firstFruit = firstFruit[:-1] +firstWeight = tupleFive[1] +secondFruit = tupleFive[2] +secondFruit = secondFruit[:-1] +secondWeight = tupleFive[3] +print(f"The weight of an {firstFruit} is {firstWeight} and the weight of a {secondFruit} is {secondWeight}") + +print(f"The weight of an {firstFruit.upper()} is {firstWeight * 1.2} and the weight of a {secondFruit.upper()} is {secondWeight * 1.2}") +# The weight of an orange is 1.3 and the weight of a lemon is 1.1 + +# Task six From 1b73c2b3e9bae7e980b576abf576213b57b4e19c Mon Sep 17 00:00:00 2001 From: Robert Kesterson Date: Tue, 29 Jan 2019 05:49:04 -0800 Subject: [PATCH 06/30] Mostly done with labs. On to mailroom assignment --- .../robert_kesterson/session03/mailroom.py | 11 ++++ .../robert_kesterson/session03/slicing_lab.py | 54 +++++++++++++++++++ .../session03/strformatlab.py | 7 +-- 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 students/robert_kesterson/session03/mailroom.py create mode 100644 students/robert_kesterson/session03/slicing_lab.py diff --git a/students/robert_kesterson/session03/mailroom.py b/students/robert_kesterson/session03/mailroom.py new file mode 100644 index 0000000..83752c7 --- /dev/null +++ b/students/robert_kesterson/session03/mailroom.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 + +# -------------------------------------------- # +# Title: Lesson 03 Exercise: Mailroom, part 1 +# Desc: First major assignment +# Change log: (who, when, what) +# RKesterson, 2019-01-29, Created file +# RKestesron, 2019-01-29, Stubbed out methods / parts +# RKesterson, 2019-01-29, Started task one +# ---------------------------------------------- # + diff --git a/students/robert_kesterson/session03/slicing_lab.py b/students/robert_kesterson/session03/slicing_lab.py new file mode 100644 index 0000000..ad502d5 --- /dev/null +++ b/students/robert_kesterson/session03/slicing_lab.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 + +# -------------------------------------------- # +# Title: Lesson 03 Exercise: Slicing lab +# Desc: This is a lab where we will learn about slicing +# Change log: (who, when, what) +# RKesterson, 2019-01-29, Created file +# RKestesron, 2019-01-29, Stubbed out methods / parts +# RKesterson, 2019-01-29, Started task one (asked question about this in lesson 03 code chat forum) +# RKesterson, 2019-01-29, Completed task two +# RKesterson, 2019-01-29, Completed task three +# RKesterson, 2019-01-29, Completed task four +# RKesterson, 2019-01-29, Completed task five +# ---------------------------------------------- # + +a_string = "this is a string" +a_tuple = (2, 54, 13, 12, 5, 32) + +# Task one +def exchange_first_last(seq): + return seq[-1] + seq[1:-1] + seq[0] + +assert exchange_first_last(a_string) == "ghis is a strint" +assert exchange_first_last(a_tuple) == (32, 54, 13, 12, 5, 2) + +# Task two +def remove_every_other(seq): + return seq[0:len(seq):2] + +assert remove_every_other(a_string) == "ti sasrn" +assert remove_every_other(a_tuple) == (2, 13, 5) + +# Task three +def remove_four_starting_and_end(seq): + return seq[4:-4] + +assert remove_four_starting_and_end(a_string) == " is a st" +assert remove_four_starting_and_end(a_tuple) == () + +# Task four +def reverse_sequence(seq): + return seq[::-1] + +assert reverse_sequence(a_string) == "gnirts a si siht" +assert reverse_sequence(a_tuple) == (32, 5, 12, 13, 54, 2) + +# Task five +def thirds_manipulator(seq): + length = len(seq) + thirds = int(length / 3) + return seq[thirds * 2: length] + seq[0: thirds] + seq[thirds: thirds * 2] + +assert thirds_manipulator(a_string) == "stringthis is a " +assert thirds_manipulator(a_tuple) == (5, 32, 2, 54, 13, 12) \ No newline at end of file diff --git a/students/robert_kesterson/session03/strformatlab.py b/students/robert_kesterson/session03/strformatlab.py index a2e68ed..b7d3343 100644 --- a/students/robert_kesterson/session03/strformatlab.py +++ b/students/robert_kesterson/session03/strformatlab.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 # -------------------------------------------- # -# Title: Lesson 03 Exercise: List Lab -# Desc: This is a lab where we will learn about list manipulation +# Title: Lesson 03 Exercise: String formatting lab +# Desc: This is a lab where we will learn about string formatting in Python # Change log: (who, when, what) # RKesterson, 2019-01-28, Created file # RKestesron, 2019-01-28, Stubbed out methods / parts @@ -11,7 +11,7 @@ # RKesterson, 2019-01-28, Completed task three # RKesterson, 2019-01-28, Completed task four # RKesterson, 2019-01-28, Completed task five -# RKesterson, 2019-01-28, Completed task six +# RKesterson, 2019-01-28, Started task six # ---------------------------------------------- # # Task one @@ -72,3 +72,4 @@ def formatmethod(input_tuple): # The weight of an orange is 1.3 and the weight of a lemon is 1.1 # Task six +# Will return \ No newline at end of file From e0329e5be68e66edf130f758760010dc3b5f7a6c Mon Sep 17 00:00:00 2001 From: Robert Kesterson Date: Tue, 29 Jan 2019 06:02:49 -0800 Subject: [PATCH 07/30] working on mailroom --- students/robert_kesterson/session03/list_lab.py | 2 +- students/robert_kesterson/session03/mailroom.py | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/students/robert_kesterson/session03/list_lab.py b/students/robert_kesterson/session03/list_lab.py index fb1ce94..51bd8fe 100644 --- a/students/robert_kesterson/session03/list_lab.py +++ b/students/robert_kesterson/session03/list_lab.py @@ -40,7 +40,7 @@ response = input("Do you like " + fruit.lower() + " ? (yes / no) ") if response == "no": listSeriesOne.remove(fruit) - while response != 'yes' and response != "no": + while response != "yes" and response != "no": response = input("Answer must be \"yes\" or \"no\". Do you like " + fruit.lower() + " ? (yes / no) ") print(listSeriesOne) diff --git a/students/robert_kesterson/session03/mailroom.py b/students/robert_kesterson/session03/mailroom.py index 83752c7..e09172e 100644 --- a/students/robert_kesterson/session03/mailroom.py +++ b/students/robert_kesterson/session03/mailroom.py @@ -9,3 +9,13 @@ # RKesterson, 2019-01-29, Started task one # ---------------------------------------------- # +response = input("Choose an action: Send a Thank You, Create a Report, quit") +if response == "Send a Thank You": + #Add code here +if response == "Create a Report": + #Add code here +if response == "quit": + #Add code here +while response != "Send a Thank You" and response != "Create a Report" and response != "quit": + response = input("You must chose an action from the approved list. Actions are: Send a Thank you, " + "Create a Report, quit") \ No newline at end of file From 0f8e5e3d2eecddebaa87ba17b53bdab9e27c68a8 Mon Sep 17 00:00:00 2001 From: Robert Kesterson Date: Tue, 29 Jan 2019 17:15:51 -0800 Subject: [PATCH 08/30] checking in mailroom code --- .../robert_kesterson/session03/mailroom.py | 78 ++++++++++++++++--- 1 file changed, 67 insertions(+), 11 deletions(-) diff --git a/students/robert_kesterson/session03/mailroom.py b/students/robert_kesterson/session03/mailroom.py index e09172e..de362d8 100644 --- a/students/robert_kesterson/session03/mailroom.py +++ b/students/robert_kesterson/session03/mailroom.py @@ -6,16 +6,72 @@ # Change log: (who, when, what) # RKesterson, 2019-01-29, Created file # RKestesron, 2019-01-29, Stubbed out methods / parts -# RKesterson, 2019-01-29, Started task one +# RKesterson, 2019-01-29, Started defining load_donation_list # ---------------------------------------------- # -response = input("Choose an action: Send a Thank You, Create a Report, quit") -if response == "Send a Thank You": - #Add code here -if response == "Create a Report": - #Add code here -if response == "quit": - #Add code here -while response != "Send a Thank You" and response != "Create a Report" and response != "quit": - response = input("You must chose an action from the approved list. Actions are: Send a Thank you, " - "Create a Report, quit") \ No newline at end of file +donationlist = [] + +def load_donation_list(): + global donationlist + firstdonation = ("Winston Churchill", 2) + donationlist.append(firstdonation) + firstdonation = ("Winston Churchill", 20) + donationlist.append(firstdonation) + firstdonation = ("Hunter S. Thompson", 50) + donationlist.append(firstdonation) + firstdonation = ("Hunter S. Thompson", 500) + donationlist.append(firstdonation) + firstdonation = ("Hunter S. Thompson", 5000) + donationlist.append(firstdonation) + firstdonation = ("Richard Garfield", 300) + donationlist.append(firstdonation) + firstdonation = ("Richard Garfield", 400) + donationlist.append(firstdonation) + firstdonation = ("Simon Illyan", 100) + donationlist.append(firstdonation) + firstdonation = ("Theodore Roosevelt", 50) + donationlist.append(firstdonation) + firstdonation = ("Theodore Roosevelt", 100) + donationlist.append(firstdonation) + +def send_thank_you(): + global donationlist + tyresponse = input("Please enter a full name. list provides all names") + while True: + if tyresponse == "list": + donationlist.sort() + namelist = "" + for tupleobject in donationlist: + if tupleobject[0] not in namelist and namelist == "": + namelist = namelist + "{:s}".format(tupleobject[0]) + elif tupleobject[0] not in namelist: + namelist = namelist + ",{:s}".format(tupleobject[0]) + print(namelist) + tyresponse = input("Please enter a full name. List provides all names") + else: + donation = input("Enter a donation amount") + donation = int(donation) + newdonation = (tyresponse, donation) + print("Thank you {:s} for your generous donation of {:d} dollars".format(newdonation[0], newdonation[1])) + donationlist.append(newdonation) + break + +def create_a_report(): + print("hello") + +if __name__ == '__main__': + load_donation_list() + + response = input("Choose an action: Send a Thank You, Create a Report, quit") + while True: + if response == "Send a Thank You": + send_thank_you() + response = input("Choose an action: Send a Thank You, Create a Report, quit") + elif response == "Create a Report": + create_a_report() + response = input("Choose an action: Send a Thank You, Create a Report, quit") + elif response == "quit": + break + else: + response = input("You must chose an action from the approved list. Actions are: Send a Thank you, " + "Create a Report, quit") From 3c527e718b5275ba02518e32ac5536735da4ed3f Mon Sep 17 00:00:00 2001 From: Robert Kesterson Date: Tue, 29 Jan 2019 17:54:33 -0800 Subject: [PATCH 09/30] final push for mailroom.py --- .../robert_kesterson/session03/mailroom.py | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/students/robert_kesterson/session03/mailroom.py b/students/robert_kesterson/session03/mailroom.py index de362d8..deb3a92 100644 --- a/students/robert_kesterson/session03/mailroom.py +++ b/students/robert_kesterson/session03/mailroom.py @@ -57,7 +57,36 @@ def send_thank_you(): break def create_a_report(): - print("hello") + i = 1 + reportlist = [] + currentname = "" + totalgiven = 0 + numberofgifts = 0 + donationlist.sort() + # If the currentname is the empty set, we have not started to iterate yet + for tupleobject in donationlist: + if currentname == "": + currentname = tupleobject[0] + totalgiven = tupleobject[1] + numberofgifts = 1 + # If we encounter a different name from the current name, we know we have reached a new donor + elif currentname != tupleobject[0]: + reporttuple = (totalgiven, currentname, numberofgifts) + reportlist.append(reporttuple) + currentname = tupleobject[0] + totalgiven = tupleobject[1] + numberofgifts = 1 + # If we encounter the same name, we want to add to the information about said donor + else: + totalgiven += tupleobject[1] + numberofgifts += 1 + + # Now that the tuples are totaled, we can sort and print them + reportlist.sort() + reportlist.reverse() + for tupleobject in reportlist: + print("{:s} {:d} {:d}") + if __name__ == '__main__': load_donation_list() From aec8cbcf207b9291a6a10440c9642ebccd8f38f6 Mon Sep 17 00:00:00 2001 From: Robert Kesterson Date: Wed, 30 Jan 2019 18:19:09 -0800 Subject: [PATCH 10/30] Restructuring for requested format and stubbing out session04 assignments --- students/robert_kesterson/.idea/workspace.xml | 333 ++++++++++++++++++ .../list_1_first_last6.py | 0 .../list_1_same_first_last.py | 0 .../logic_1_cigar_party.py | 0 .../logic_1_date_fashion.py | 0 .../string_1_hello_name.py | 0 .../string_1_make_abba.py | 0 .../warmup_1_monkey_trouble.py | 0 .../warmup_1_sleep_in.py | 0 .../lesson_02_fibonacci_series.py | 0 .../lesson_02_exercise_fizz_buzz.py | 0 .../lesson_02_exercise_grid_printer.py | 0 .../list_2_big_diff.py | 0 .../list_2_count_evens.py | 0 .../logic_2_lone_sum.py | 0 .../logic_2_lucky_sum.py | 0 .../string_2_count_hi.py | 0 .../string_2_double_char.py | 0 .../warmup_2_front_times.py | 0 .../warmup_2_string_times.py | 0 .../robert_kesterson/session04/dictlab.py | 18 + .../session04/katafourteen.py | 12 + .../session04/mailroompart2.py | 11 + 23 files changed, 374 insertions(+) rename students/robert_kesterson/{ => session01}/lesson_01_python_pushups_1_of_2/list_1_first_last6.py (100%) rename students/robert_kesterson/{ => session01}/lesson_01_python_pushups_1_of_2/list_1_same_first_last.py (100%) rename students/robert_kesterson/{ => session01}/lesson_01_python_pushups_1_of_2/logic_1_cigar_party.py (100%) rename students/robert_kesterson/{ => session01}/lesson_01_python_pushups_1_of_2/logic_1_date_fashion.py (100%) rename students/robert_kesterson/{ => session01}/lesson_01_python_pushups_1_of_2/string_1_hello_name.py (100%) rename students/robert_kesterson/{ => session01}/lesson_01_python_pushups_1_of_2/string_1_make_abba.py (100%) rename students/robert_kesterson/{ => session01}/lesson_01_python_pushups_1_of_2/warmup_1_monkey_trouble.py (100%) rename students/robert_kesterson/{ => session01}/lesson_01_python_pushups_1_of_2/warmup_1_sleep_in.py (100%) rename students/robert_kesterson/{ => session02}/lesson_02_exercise_fibonacci_series/lesson_02_fibonacci_series.py (100%) rename students/robert_kesterson/{ => session02}/lesson_02_exercise_fizz_buzz/lesson_02_exercise_fizz_buzz.py (100%) rename students/robert_kesterson/{ => session02}/lesson_02_exercise_grid_printer/lesson_02_exercise_grid_printer.py (100%) rename students/robert_kesterson/{ => session02}/lesson_02_python_pushups_2_of_2/list_2_big_diff.py (100%) rename students/robert_kesterson/{ => session02}/lesson_02_python_pushups_2_of_2/list_2_count_evens.py (100%) rename students/robert_kesterson/{ => session02}/lesson_02_python_pushups_2_of_2/logic_2_lone_sum.py (100%) rename students/robert_kesterson/{ => session02}/lesson_02_python_pushups_2_of_2/logic_2_lucky_sum.py (100%) rename students/robert_kesterson/{ => session02}/lesson_02_python_pushups_2_of_2/string_2_count_hi.py (100%) rename students/robert_kesterson/{ => session02}/lesson_02_python_pushups_2_of_2/string_2_double_char.py (100%) rename students/robert_kesterson/{ => session02}/lesson_02_python_pushups_2_of_2/warmup_2_front_times.py (100%) rename students/robert_kesterson/{ => session02}/lesson_02_python_pushups_2_of_2/warmup_2_string_times.py (100%) create mode 100644 students/robert_kesterson/session04/dictlab.py create mode 100644 students/robert_kesterson/session04/katafourteen.py create mode 100644 students/robert_kesterson/session04/mailroompart2.py diff --git a/students/robert_kesterson/.idea/workspace.xml b/students/robert_kesterson/.idea/workspace.xml index 19771ef..5b50aca 100644 --- a/students/robert_kesterson/.idea/workspace.xml +++ b/students/robert_kesterson/.idea/workspace.xml @@ -1,9 +1,342 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +