Learn Python – Code Example – BlackJack

Learn Blackjack Video Source & Info:

Learn Python – BlackJack

In this video:
– Functions
– Nested for loops
– While loops
– If statements
– Comments

— Welcome to Coding4Chicks —

I am a programming chick with 10 years of experience in programming and the administration of computer systems. I have a masters in Software Engineering, a bachelors in Computer Science and have been teaching at University.

I dedicate this channel to my Chicas around the world that would also like to learn programming but don’t know where to start. This channel is in no way an indication that you will need special help in learning anything, sometimes we just feel like listening to a girl.

P.S. Boys, feel free to enjoy the site too! πŸ˜‰

Remember: The sky is the limit. You can do anything you want!

Source: YouTube

Share this video:
Learn Python – Code Example – BlackJack

10 thoughts on “Learn Python – Code Example – BlackJack

  1. dealerHand.append(myDeck.pop()) [LINE 41]
    #i dont get it this part. im having an error. "IndexError: pop from empty list"
    please help me

  2. I have a problem when I "run the module" and I have this error: myCount += int(i[1])
    ValueError: invalid literal for int() with base 10: 'T'

  3. https://github.com/osk4r99/School-projekt/blob/master/blackjack/blackjack(pyqt).py
    Here is great graphical blackjack game if anyone interested

  4. Can someone please fix this im using pycharm btw

    from random import shuffle

    def deck():
    deck = []
    for suit in ['H️', '️S', 'D', 'C️']:
    for rank in ['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']:
    deck.append(suit + rank)

    shuffle(deck)

    return deck

    def pointCount(myCards):
    myCount = 0
    aceCount = 0

    for i in myCards:
    if (i[1] == 'J' or i[1] == 'Q' or i[1] == 'K' or i[1] == 'T'):
    myCount += 10
    elif (i[1] != 'A'):
    myCount += int(i[1])
    else:
    aceCount += 1

    if (aceCount == 1 and myCount >= 10):
    myCount += 11
    elif(aceCount != 0):
    myCount += 1

    return myCount

    def createPlayingHands(myDeck):
    dealerHand = []
    playerHand = []
    dealerHand.append(myDeck.pop())
    dealerHand.append(myDeck.pop())
    playerHand.append(myDeck.pop())
    playerHand.append(myDeck.pop())

    while (pointCount(dealerHand) <= 15):
    dealerHand.append(myDeck.pop())

    return [dealerHand, playerHand]

    game = ""
    myDeck = deck()
    hands = createPlayingHands(myDeck)
    dealer = hands[0]
    player = hands[1]

    while (game != "exit"):
    dealerCount = pointCount(dealer)
    playerCount = pointCount(player)

    print "Dealer has:"
    print dealer[0]

    print "Player1, you have:"
    print player

    if (playerCount == 21):
    print "You Won!"
    break
    elif (playerCount > 21):
    print "Player BUSTS with " + str(playerCount) + " points. Dealer wins."
    break
    elif (dealerCount > 21):
    print "Dealer BUSTS with " + str(playerCount) + " points. Player wins!"
    break

    game = raw_input("Stand (S) or Hit (H)? ")

    if (game == 'H'):
    player.append(myDeck.pop())
    elif (playerCount > dealerCount):
    print "Player wins with " + str(playerCount) + " points"
    print "Dealer has: " + str(dealer) + " or " + str(dealerCount) + "points"
    break
    else:
    print "Dealer wins."
    print "Dealer has: " + str(dealer) + " or " + str(dealerCount) + "points"
    break

  5. Wait I have a questions if for your assignment your not allowed to use .pop what else can you use for that?

Comments are closed.