From 4f9753d2e332459041704569ba0d04a386b20996 Mon Sep 17 00:00:00 2001 From: Zachary Christman Date: Wed, 13 Jul 2022 23:23:25 -0400 Subject: [PATCH 1/3] Finished lab 5. --- code/zach/lab05-pick6.py | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 code/zach/lab05-pick6.py diff --git a/code/zach/lab05-pick6.py b/code/zach/lab05-pick6.py new file mode 100644 index 00000000..e86afcbf --- /dev/null +++ b/code/zach/lab05-pick6.py @@ -0,0 +1,54 @@ +import random + +def pick6(): + index = 0 + winning = [] + ticket = [] + + while index < 6: + winning.append(random.choice(range(1, 100))) + ticket.append(random.choice(range(1, 100))) + index += 1 + + return winning, ticket + +def num_matches(winning, ticket): + index = 0 + matches = 0 + + while index < 6: + if winning[index] == ticket[index]: + matches += 1 + + index += 1 + + return matches + +def main(): + index = 0 + balance = 0 + + while index < 100000: + winning, ticket = pick6() + matches = num_matches(winning, ticket) + + if matches == 0: + balance -= 2 + elif matches == 1: + balance += 2 + elif matches == 2: + balance += 5 + elif matches == 3: + balance += 98 + elif matches == 4: + balance += 49998 + elif matches == 5: + balance += 999998 + elif matches == 6: + balance += 24999998 + + index += 1 + + return print(f'Final Balance: {balance}') + +main() \ No newline at end of file From 9e055cdb025531d3e9d627f2a492144f865ef903 Mon Sep 17 00:00:00 2001 From: Zachary Christman Date: Wed, 20 Jul 2022 21:25:23 -0400 Subject: [PATCH 2/3] Corrected lab 5 to include Version 2. --- code/zach/lab05-pick6.py | 24 +++++++++++++++--------- code/zach/lab09-quotes-api.py | 2 ++ 2 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 code/zach/lab09-quotes-api.py diff --git a/code/zach/lab05-pick6.py b/code/zach/lab05-pick6.py index e86afcbf..f399fc93 100644 --- a/code/zach/lab05-pick6.py +++ b/code/zach/lab05-pick6.py @@ -27,28 +27,34 @@ def num_matches(winning, ticket): def main(): index = 0 balance = 0 + earnings = 0 + expenses = 0 while index < 100000: winning, ticket = pick6() matches = num_matches(winning, ticket) if matches == 0: - balance -= 2 + earnings += 0 elif matches == 1: - balance += 2 + earnings += 4 elif matches == 2: - balance += 5 + earnings += 7 elif matches == 3: - balance += 98 + earnings += 100 elif matches == 4: - balance += 49998 + earnings += 50000 elif matches == 5: - balance += 999998 + earnings += 1000000 elif matches == 6: - balance += 24999998 + earnings += 25000000 + expenses -= 2 index += 1 - - return print(f'Final Balance: {balance}') + + balance = earnings + expenses + ROI = (earnings + expenses) / expenses + + return print(f'Final Balance: {balance}'), print(f'ROI: {ROI}') main() \ No newline at end of file diff --git a/code/zach/lab09-quotes-api.py b/code/zach/lab09-quotes-api.py new file mode 100644 index 00000000..fc75f013 --- /dev/null +++ b/code/zach/lab09-quotes-api.py @@ -0,0 +1,2 @@ +import requests + From 52a966a8f5b60ecee38aed8ae3d37e1a23da9b2f Mon Sep 17 00:00:00 2001 From: Zachary Christman <31595212+x8bitReignbeaux@users.noreply.github.com> Date: Fri, 22 Jul 2022 21:40:06 -0400 Subject: [PATCH 3/3] Delete lab09-quotes-api.py Fixing commit conflict. --- code/zach/lab09-quotes-api.py | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 code/zach/lab09-quotes-api.py diff --git a/code/zach/lab09-quotes-api.py b/code/zach/lab09-quotes-api.py deleted file mode 100644 index fc75f013..00000000 --- a/code/zach/lab09-quotes-api.py +++ /dev/null @@ -1,2 +0,0 @@ -import requests -