Project: Blackjack¶
Name this file as blackjack.py
Write a program that allows a human user to play a simplified version of Blackjack against a computer opponent. Make it as cool as you can.
The simplified blackjack rules are as follows:
Don’t worry about suits or face cards; “cards” will have values from 2-11, and all values are equally likely (that is, unlike a real blackjack game, there’s no greater chance of drawing a card with value 10).
Draw two cards for the player and display them.
Draw two cards for the “dealer” and display one of them, keeping the other one hidden.
Allow the player to “hit” as many times as he would like.
If the player “busts” (gets a total over 21), the dealer automatically wins.
Allow the dealer to hit as many times as he would like. Dealer should probably hit on sixteen or lower.
If the dealer busts, the player automatically wins.
Assuming no one has busted, the player with the highest total wins. Dealer wins all ties.
As will be the case with all projects, this is not an assigment with a fixed goal. Programs that merely do what is listed above will be passing, but will certainly not be worth 100. In order to score a high grade, programs must go above and beyond the specifications. Here are suggested additional features to add:
Use realistic card values, with suits and faces from ace to king.
Incorporate wagering.
Display some sort of graphical cards.
Anything else interesting you can think of.
Be aware that you won’t get any extra points for adding additional features if the basic program doesn’t work. That is, if your program can’t successfully do the basics listed above, no amount of bells and whistles will save your grade. Programs will be graded on the following criteria:
Functionality - Does your program fulfill the basic requirements? Is it done? And what else does it do? (50%)
Overall Impression - Is your program efficiently organized, or is there a lot of duplicated code? Does it look well-written, or barely finished? (25%)
Bugs - does it compile? Are there obvious errors? Are there subtle errors? (10%)
Internal Documentation - How easy is your code to understand? Are you using good variable names? Are there any comments? (10%)
Readability - Is your program consistently indented in a manner that reflects the structure of your code? Is it easy to read? Are there blank lines which break up the major sections of your code? (5%)
Welcome to Mitchell's blackjack program!
You get a 6 and a 5.
Your total is 11.
The dealer has a 7 showing, and a hidden card.
His total is hidden, too.
Would you like to "hit" or "stay"? hit
You drew a 8.
Your total is 19.
Would you like to "hit" or "stay"? stay
Okay, dealer's turn.
His hidden card was a 3.
His total was 10.
Dealer chooses to hit.
He draws a 7.
His total is 17.
Dealer stays.
Dealer total is 17.
Your total is 19.
YOU WIN!
©2021 Daniel Gallo
This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Adapted for Python from Graham Mitchell’s Programming By Doing