From be75ea138641daee992ed00ed1584b5b6b5685b9 Mon Sep 17 00:00:00 2001 From: Guido Knips Date: Mon, 28 Aug 2023 20:41:55 +0200 Subject: [PATCH 1/2] Fix pick of pollution reason in python King - was intended to pick only one random reason each time - picked up to five reasons - also removed bad line break --- 53_King/python/king.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/53_King/python/king.py b/53_King/python/king.py index a4d9b7696..4bca76fac 100644 --- a/53_King/python/king.py +++ b/53_King/python/king.py @@ -131,17 +131,17 @@ def handle_tourist_trade(self) -> None: tourist_trade_earnings = V1 - V2 print(f" YOU MADE {tourist_trade_earnings} RALLODS FROM TOURIST TRADE.") if V2 != 0 and not (V1 - V2 >= self.tourism_earnings): - print(" DECREASE BECAUSE ") + print(" DECREASE BECAUSE ", end="") reason = randint(0, 10) if reason <= 2: print("FISH POPULATION HAS DWINDLED DUE TO WATER POLLUTION.") - if reason <= 4: + elif reason <= 4: print("AIR POLLUTION IS KILLING GAME BIRD POPULATION.") - if reason <= 6: + elif reason <= 6: print("MINERAL BATHS ARE BEING RUINED BY WATER POLLUTION.") - if reason <= 8: + elif reason <= 8: print("UNPLEASANT SMOG IS DISCOURAGING SUN BATHERS.") - if reason <= 10: + else: print("HOTELS ARE LOOKING SHABBY DUE TO SMOG GRIT.") # NOTE: The following two lines had a bug in the original game: From fa4f6888ddabea2b3d1fe86d2d5393b2b66b0cb6 Mon Sep 17 00:00:00 2001 From: Guido Knips Date: Mon, 28 Aug 2023 20:57:27 +0200 Subject: [PATCH 2/2] Fix flake8 issues in acey ducey - came seemingly out of nowhere and broke my totally unrelated PR --- 01_Acey_Ducey/python/acey_ducey.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/01_Acey_Ducey/python/acey_ducey.py b/01_Acey_Ducey/python/acey_ducey.py index 8e3535695..75a1eac27 100755 --- a/01_Acey_Ducey/python/acey_ducey.py +++ b/01_Acey_Ducey/python/acey_ducey.py @@ -6,6 +6,7 @@ import random + cards = { 2: "2", 3: "3", @@ -22,18 +23,19 @@ 14: "Ace", } + def play_game() -> None: cash = 100 while cash > 0: print(f"You now have {cash} dollars\n") print("Here are you next two cards") - round_cards = list(cards.keys()) # gather cards from dictionary - card_a = random.choice(round_cards) # choose a card - card_b = card_a # clone the first card, so we avoid the same number for the second card - while (card_a == card_b): # if the cards are the same, choose another card + round_cards = list(cards.keys()) # gather cards from dictionary + card_a = random.choice(round_cards) # choose a card + card_b = card_a # clone the first card, so we avoid the same number for the second card + while (card_a == card_b): # if the cards are the same, choose another card card_b = random.choice(round_cards) - card_c = random.choice(round_cards) # choose last card - if card_a > card_b: # swap cards if card_a is greater than card_b + card_c = random.choice(round_cards) # choose last card + if card_a > card_b: # swap cards if card_a is greater than card_b card_a, card_b = card_b, card_a print(f" {cards[card_a]}") print(f" {cards[card_b]}\n")