Creating a Simple PYTHON App - #3 - The BlackJack Case Study

preview_player
Показать описание
This video describes the code necessary to implement a 2 person BlackJack game in Python. I took this code from the excellent text "Intro to Computing using Python" by Perkovic (Wiley). An excellent text for anyone learning Python. This case study is only appropriate *after* someone has covered the basics of Python, which include how to use all the main data types and structures (such as dictionaries). It is intended to show the huge benefit in developing a discipline of unit testing and blackbox design *before* starting to write code. This completes the education of our app building process: learning about testing, organizing what code modules we need and how they should interface; and *finally* writing the code.
Рекомендации по теме
Комментарии
Автор

This has been a really fun intro to programming with python, and a great general refresher on how to plan and build a small app. Thanks!

adamduncan
Автор

Thank you sir for such a lucid and in depth explanation!
I hope you get to impart knowledge to masses through this channel. All the best!

abhishekbasra
Автор

Thanks, Dave for this wonderful video!

tejaskulkarni
Автор

Hi Dave,
Thank you for this video and such good explanation.

I am writing the code exactly the same as you did but for my second unit test I am getting different results. I am using Python 3 (3.7.4) and Jupyter Notebook. I tried this code on command prompt too but similar result. Following is from Jupyter Notebook:

import random

def shuffleDeck():
suits = ['\u2660', '\u2661', '\u2662', '\u2663']
ranks = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
deck = [ ]

for suit in suits:
for rank in ranks:
deck.append(rank + suit)

random.shuffle(deck)
return deck

def dealCard(deck, player):
card = deck.pop
player.append(card)
return card

# test case 2
myDeck = shuffleDeck()
dave = [ ]
dealCard(myDeck, dave)

<function list.pop(index=-1, /)>

dave
[<function list.pop(index=-1, /)>]

print(dave)
[<built-in method pop of list object at

noodless
Автор

Why do the keys in the dictionary only match to the first letter/number in the string? And how would you change that? Have '10':10 and 'King':10 for example.

GagGreene
Автор

cool vid! shouldn't we move the conditional portion "houseTotal == 21 and 2 == len(house) < len(player)" above? otherwise we will never know if the player or the house won with blackjack. at least in Ruby!

franciscobach