diff --git a/students/RobertKesterson/.idea/vcs.xml b/students/RobertKesterson/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/students/RobertKesterson/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/students/RobertKesterson/lesson_01_python_pushups_1_of_2/list_1_first_last6.py b/students/RobertKesterson/lesson_01_python_pushups_1_of_2/list_1_first_last6.py new file mode 100644 index 0000000..5e5d2c5 --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_01_python_pushups_1_of_2/list_1_same_first_last.py b/students/RobertKesterson/lesson_01_python_pushups_1_of_2/list_1_same_first_last.py new file mode 100644 index 0000000..4a0755d --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_01_python_pushups_1_of_2/logic_1_cigar_party.py b/students/RobertKesterson/lesson_01_python_pushups_1_of_2/logic_1_cigar_party.py new file mode 100644 index 0000000..e9bdfe9 --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_01_python_pushups_1_of_2/logic_1_date_fashion.py b/students/RobertKesterson/lesson_01_python_pushups_1_of_2/logic_1_date_fashion.py new file mode 100644 index 0000000..c92851d --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_01_python_pushups_1_of_2/string_1_hello_name.py b/students/RobertKesterson/lesson_01_python_pushups_1_of_2/string_1_hello_name.py new file mode 100644 index 0000000..9077287 --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_01_python_pushups_1_of_2/string_1_make_abba.py b/students/RobertKesterson/lesson_01_python_pushups_1_of_2/string_1_make_abba.py new file mode 100644 index 0000000..09f06d8 --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_01_python_pushups_1_of_2/warmup_1_monkey_trouble.py b/students/RobertKesterson/lesson_01_python_pushups_1_of_2/warmup_1_monkey_trouble.py new file mode 100644 index 0000000..b3aac06 --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_01_python_pushups_1_of_2/warmup_1_sleep_in.py b/students/RobertKesterson/lesson_01_python_pushups_1_of_2/warmup_1_sleep_in.py new file mode 100644 index 0000000..161e925 --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_02_exercise_fibonacci_series/lesson_02_fibonacci_series.py b/students/RobertKesterson/lesson_02_exercise_fibonacci_series/lesson_02_fibonacci_series.py new file mode 100644 index 0000000..a17597d --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_02_exercise_fizz_buzz/lesson_02_exercise_fizz_buzz.py b/students/RobertKesterson/lesson_02_exercise_fizz_buzz/lesson_02_exercise_fizz_buzz.py new file mode 100644 index 0000000..c78b9f3 --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_02_exercise_grid_printer/lesson_02_exercise_grid_printer.py b/students/RobertKesterson/lesson_02_exercise_grid_printer/lesson_02_exercise_grid_printer.py new file mode 100644 index 0000000..84925cb --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_02_python_pushups_2_of_2/list_2_big_diff.py b/students/RobertKesterson/lesson_02_python_pushups_2_of_2/list_2_big_diff.py new file mode 100644 index 0000000..326e6b8 --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_02_python_pushups_2_of_2/list_2_count_evens.py b/students/RobertKesterson/lesson_02_python_pushups_2_of_2/list_2_count_evens.py new file mode 100644 index 0000000..3167143 --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_02_python_pushups_2_of_2/logic_2_lone_sum.py b/students/RobertKesterson/lesson_02_python_pushups_2_of_2/logic_2_lone_sum.py new file mode 100644 index 0000000..8f57685 --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_02_python_pushups_2_of_2/logic_2_lucky_sum.py b/students/RobertKesterson/lesson_02_python_pushups_2_of_2/logic_2_lucky_sum.py new file mode 100644 index 0000000..10153ac --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_02_python_pushups_2_of_2/string_2_count_hi.py b/students/RobertKesterson/lesson_02_python_pushups_2_of_2/string_2_count_hi.py new file mode 100644 index 0000000..791cbce --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_02_python_pushups_2_of_2/string_2_double_char.py b/students/RobertKesterson/lesson_02_python_pushups_2_of_2/string_2_double_char.py new file mode 100644 index 0000000..186c1b5 --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_02_python_pushups_2_of_2/warmup_2_front_times.py b/students/RobertKesterson/lesson_02_python_pushups_2_of_2/warmup_2_front_times.py new file mode 100644 index 0000000..e44b5af --- /dev/null +++ b/students/RobertKesterson/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/RobertKesterson/lesson_02_python_pushups_2_of_2/warmup_2_string_times.py b/students/RobertKesterson/lesson_02_python_pushups_2_of_2/warmup_2_string_times.py new file mode 100644 index 0000000..dd62cc5 --- /dev/null +++ b/students/RobertKesterson/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 diff --git a/students/RobertKesterson/readme.txt b/students/RobertKesterson/readme.txt new file mode 100644 index 0000000..dcd9636 --- /dev/null +++ b/students/RobertKesterson/readme.txt @@ -0,0 +1 @@ +This is the base readme to create the new txt file that is needed.