From 048c002e6901fecaa9d30aad972dfa9cbe69a83d Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Sun, 7 Feb 2021 17:04:29 -0500 Subject: [PATCH 01/12] Solve 5.3.2 --- 5/5.3/5.3.2/main.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 5/5.3/5.3.2/main.py diff --git a/5/5.3/5.3.2/main.py b/5/5.3/5.3.2/main.py new file mode 100644 index 0000000..30e7397 --- /dev/null +++ b/5/5.3/5.3.2/main.py @@ -0,0 +1,19 @@ +def find_max(num_1, num_2): + max_val = 0.0 + + if (num_1 > num_2): # if num1 is greater than num2, + max_val = num_1 # then num1 is the maxVal. + else: # Otherwise, + max_val = num_2 # num2 is the maxVal + return max_val + +max_sum = 0.0 + +num_a = float(input()) +num_b = float(input()) +num_y = float(input()) +num_z = float(input()) + +max_sum = sum([max([num_a, num_b]), max([num_y, num_z])]) + +print('max_sum is:', max_sum) \ No newline at end of file From 3d2870eb2cfe8fac3da8343c066240a4d005b300 Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Sun, 7 Feb 2021 17:07:01 -0500 Subject: [PATCH 02/12] Solve 5.3.3 --- 5/5.3/5.3.3/main.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 5/5.3/5.3.3/main.py diff --git a/5/5.3/5.3.3/main.py b/5/5.3/5.3.3/main.py new file mode 100644 index 0000000..eae0ea8 --- /dev/null +++ b/5/5.3/5.3.3/main.py @@ -0,0 +1,9 @@ + +def pyramid_volume(base_length, base_width, pyramid_height): + return(((base_length * base_width) * pyramid_height) * (1/3)) + + +length = float(input()) +width = float(input()) +height = float(input()) +print('Volume for 4.5, 2.1, 3.0 is:', pyramid_volume(length, width, height)) \ No newline at end of file From 7b097ae89fda4a6d9d695f3d78cf3cfad25a4910 Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Sun, 7 Feb 2021 17:15:04 -0500 Subject: [PATCH 03/12] Cleanup 5.3.2 --- 5/5.3/5.3.2/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/5/5.3/5.3.2/main.py b/5/5.3/5.3.2/main.py index 30e7397..23f68f6 100644 --- a/5/5.3/5.3.2/main.py +++ b/5/5.3/5.3.2/main.py @@ -16,4 +16,4 @@ num_z = float(input()) max_sum = sum([max([num_a, num_b]), max([num_y, num_z])]) -print('max_sum is:', max_sum) \ No newline at end of file +print('max_sum is:', max_sum) From 52e2472d13863528dc02d7f2fb83808742a4b537 Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Sun, 7 Feb 2021 17:15:10 -0500 Subject: [PATCH 04/12] Solve 5.5.1 --- 5/5.5/5.5.1/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 5/5.5/5.5.1/main.py diff --git a/5/5.5/5.5.1/main.py b/5/5.5/5.5.1/main.py new file mode 100644 index 0000000..da6cd17 --- /dev/null +++ b/5/5.5/5.5.1/main.py @@ -0,0 +1,8 @@ + +def mph_and_minutes_to_miles(mph, dt): + return (dt / 60) * mph + +miles_per_hour = float(input()) +minutes_traveled = float(input()) + +print('Miles: {:f}'.format(mph_and_minutes_to_miles(miles_per_hour, minutes_traveled))) From 5e9c248e2f8970ff36c263766c234a96aa4dc80b Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Sun, 7 Feb 2021 17:15:29 -0500 Subject: [PATCH 05/12] Clean up 5.3.3 --- 5/5.3/5.3.3/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/5/5.3/5.3.3/main.py b/5/5.3/5.3.3/main.py index eae0ea8..5898043 100644 --- a/5/5.3/5.3.3/main.py +++ b/5/5.3/5.3.3/main.py @@ -6,4 +6,4 @@ def pyramid_volume(base_length, base_width, pyramid_height): length = float(input()) width = float(input()) height = float(input()) -print('Volume for 4.5, 2.1, 3.0 is:', pyramid_volume(length, width, height)) \ No newline at end of file +print('Volume for 4.5, 2.1, 3.0 is:', pyramid_volume(length, width, height)) From 49f7781e865044d63970de461f5a76100408fc90 Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Sun, 7 Feb 2021 17:21:26 -0500 Subject: [PATCH 06/12] Solve 5.6.1 --- 5/5.6/5.6.1/main.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 5/5.6/5.6.1/main.py diff --git a/5/5.6/5.6.1/main.py b/5/5.6/5.6.1/main.py new file mode 100644 index 0000000..c066bca --- /dev/null +++ b/5/5.6/5.6.1/main.py @@ -0,0 +1,22 @@ + +def get_user_num(): + # This is bad practice, you should use python ABC or raise NotImplementedError instead. + print('FIXME: Finish get_user_num()') + return -1 + #raise NotImplementedError + +def compute_avg(user_num1, user_num2): + # This is bad practice, you should use python ABC or raise NotImplementedError instead. + print('FIXME: Finish compute_avg()') + return -1 + #raise NotImplementedError + +user_num1 = 0 +user_num2 = 0 +avg_result = 0 + +user_num1 = get_user_num() +user_num2 = get_user_num() +avg_result = compute_avg(user_num1, user_num2) + +print('Avg:', avg_result) From 6690d9cdf474f76d090aadbac26e96ae4eb774ee Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Sun, 7 Feb 2021 17:28:18 -0500 Subject: [PATCH 07/12] solve 5.7.1 --- 5/5.7/5.7.1/main.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 5/5.7/5.7.1/main.py diff --git a/5/5.7/5.7.1/main.py b/5/5.7/5.7.1/main.py new file mode 100644 index 0000000..98e578f --- /dev/null +++ b/5/5.7/5.7.1/main.py @@ -0,0 +1,12 @@ + +def print_popcorn_time(bag_ounces): + if bag_ounces < 3: + print('Too small') # This should be returned instead. + elif bag_ounces > 10: + print('Too large') # This should be returned instead. + else: + print('{0} seconds'.format(6 * bag_ounces)) # This should be returned instead. + + +user_ounces = int(input()) +print_popcorn_time(user_ounces) From f609162053e7bd0006cfe63a3ee0ca0d1d1d6af5 Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Sun, 7 Feb 2021 21:49:11 -0500 Subject: [PATCH 08/12] solve 5.7.2 --- 5/5.7/5.7.2/main.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 5/5.7/5.7.2/main.py diff --git a/5/5.7/5.7.2/main.py b/5/5.7/5.7.2/main.py new file mode 100644 index 0000000..fbc4acb --- /dev/null +++ b/5/5.7/5.7.2/main.py @@ -0,0 +1,13 @@ + +def shampoo_instructions(num_cycles): + if num_cycles < 1: + print('Too few.') + elif num_cycles > 4: + print('Too many.') + else: + for i in range(num_cycles): + print('{0} : Lather and rinse.'.format(i + 1)) + print('Done.') + +user_cycles = int(input()) +shampoo_instructions(user_cycles) From 291fc92aa6feb28ca26328ed2b0809a40c6f34fc Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Sun, 7 Feb 2021 23:37:21 -0500 Subject: [PATCH 09/12] solve 5.12.1 --- 5/5.12/5.12.1/main.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 5/5.12/5.12.1/main.py diff --git a/5/5.12/5.12.1/main.py b/5/5.12/5.12.1/main.py new file mode 100644 index 0000000..f55733f --- /dev/null +++ b/5/5.12/5.12.1/main.py @@ -0,0 +1,9 @@ + +def swap(list): + m_list = list[0], list[-1] = list[-1], list[0] + return m_list + +values_list = input().split(',') # Program receives comma-separated values like 5,4,12,19 +swap(values_list) + +print(values_list) From 8391478991d0c5252c164bf1b6f69a24a4aca268 Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Sun, 7 Feb 2021 23:54:25 -0500 Subject: [PATCH 10/12] solve 5.17.1 --- 5/5.17/5.17.1/main.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 5/5.17/5.17.1/main.py diff --git a/5/5.17/5.17.1/main.py b/5/5.17/5.17.1/main.py new file mode 100644 index 0000000..f033cf5 --- /dev/null +++ b/5/5.17/5.17.1/main.py @@ -0,0 +1,12 @@ +gas_const = 8.3144621 + +def compute_gas_volume(pressure, temperature, moles): + return (moles * gas_const * temperature) / pressure + +gas_pressure = float(input()) +gas_moles = float(input()) +gas_temperature = float(input()) +gas_volume = 0.0 + +gas_volume = compute_gas_volume(gas_pressure, gas_temperature, gas_moles) +print('Gas volume:', gas_volume, 'm^3') From ba5ac1f29a7e7571fc18c24f2f2a6cd2e2a33b30 Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Mon, 8 Feb 2021 00:03:19 -0500 Subject: [PATCH 11/12] Solve 5.18 LAB --- 5/5.18 LAB/main.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 5/5.18 LAB/main.py diff --git a/5/5.18 LAB/main.py b/5/5.18 LAB/main.py new file mode 100644 index 0000000..4af0071 --- /dev/null +++ b/5/5.18 LAB/main.py @@ -0,0 +1,6 @@ +def swap_values(user_val1, user_val2): + return user_val2, user_val1 + +if __name__ == '__main__': + val1, val2 = swap_values(input(), input()) + print('{0} {1}'.format(val1, val2)) From 6bef49c6b2c67b4f7582748aa28e13af0750442a Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Mon, 8 Feb 2021 00:19:55 -0500 Subject: [PATCH 12/12] Solve 5.19 LAB --- 5/5.19 LAB/main.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 5/5.19 LAB/main.py diff --git a/5/5.19 LAB/main.py b/5/5.19 LAB/main.py new file mode 100644 index 0000000..b27f4fb --- /dev/null +++ b/5/5.19 LAB/main.py @@ -0,0 +1,46 @@ +coins = [ + ['Dollars', 'Dollar'], + ['Quarters', 'Quarter'], + ['Dimes', 'Dime'], + ['Nickels', 'Nickel'], + ['Pennies', 'Penny']] + +def coin_enumeration(change): + if len(change) != 0: + for coin in coins: + num_coins = change.count(coin) + if num_coins != 0: + if num_coins > 1: + print('{0} {1}'.format(num_coins, coin[0].lower())) + else: + print('{0} {1}'.format(num_coins, coin[1].lower())) + else: + print('no change') + +def fit_coin(to_make, coin_val): + num_coin = to_make // coin_val + remainder = to_make - (num_coin * coin_val) + + return num_coin, remainder + +def exact_change(input_val): + nd, input_val = fit_coin(input_val, 100) + nq, input_val = fit_coin(input_val, 25) + ndime, input_val = fit_coin(input_val, 10) + nn, input_val = fit_coin(input_val, 5) + np, input_val = fit_coin(input_val, 1) + + return nd, nq, ndime, nn, np + +if __name__ == '__main__': + change = [] + input_val = int(input()) + num_dollars, num_quarters, num_dimes, num_nickels, num_pennies = exact_change(input_val) + + change.extend([coins[0] for i in range(num_dollars)]) + change.extend([coins[1] for i in range(num_quarters)]) + change.extend([coins[2] for i in range(num_dimes)]) + change.extend([coins[3] for i in range(num_nickels)]) + change.extend([coins[4] for i in range(num_pennies)]) + + coin_enumeration(change)