""" Felix Muzny DS 2000 Lecture 19 November 12, 2024 Introduction to classes - Card class (in card.py) - diver/main code (in this file itself) make a bunch of cards and plays "blackjack" with them """ # so we can access the Card class without saying card.Card from card import Card # challenge problem: re-write this function so it works # with a list of two or more cards def blackjack(card1, card2): """ Play blackjack but only with 2 cards Aces are 1 or 11 face cards are 10 other cards are their point value :param card1: Card :param card2: Card :return: True if the card values sum to 21 """ # but actually the only way to get a blackjack with two cards is to have an # Ace and a 10/face card if card1.number == 1: return card2.number == 10 or card2.is_face() elif card2.number == 1: return card1.number == 10 or card1.is_face() return False def main(): # make and test out some cards c1 = Card(1, 1) print(c1) c2 = Card(2, 10) print(c2) c3 = Card(3, 13) print(c3) c4 = Card(4, 11) print(c4) c5 = Card(4, 11) print(c5) c6 = Card(1, 5) c7 = Card(1, 9) # see if >, < work print("comparing", c1, "greater than", c2, "?", c1 > c2) print("comparing", c1, "less than", c2, "?", c1 < c2) print("comparing", c2, "less than", c1, "?", c2 < c1) print("comparing", c4, "equal to", c5, "?", c4 == c5) print("comparing", c4, "not equal to", c5, "?", c4 != c5) print() # play blackjack print(c1, "and", c2, "are blackjack? ", blackjack(c1, c2)) print(c1, "and", c3, "are blackjack? ", blackjack(c1, c3)) print(c3, "and", c1, "are blackjack? ", blackjack(c3, c1)) print(c1, "and", c1, "are blackjack? ", blackjack(c1, c1)) print(c6, "and", c7, "are blackjack? ", blackjack(c6, c7)) print() main()