def deal_card(): cards = [2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11] # Ace is initially valued at 11 return random.choice(cards) def calculate_hand(hand); Calculates the total value of a hand, adjusting Aces to count as 1 if necessary. total = sum(hand) if total > 21 and 11 in hand: total -= 10 # Adjust Ace value to 1 return total def play_dealer(): Simulates the dealer's actions in Blackjack based on standard rules. card1 = deal_card() card2 = deal_card() dealer_hand = [card1, card2] total = calculate_hand(dealer_hand) if (card1 == 11 and card2 in [10, 10, 10, 10]) or (card2 == 11 and card1 in [10, 10, 10, 10]): print("Dealer has Blackjack!") elif total < 17: print(f"Dealer's hand: {total}, hitting...") dealer_hand.append(deal_card()) total = calculate_hand(dealer_hand) if total > 21: print("Dealer busted!") else: print(f"Dealer's final hand: {total}") else: print(f"Dealer's final hand: {total}")