UO Problem Solving and Programming
Programming Assignment 3
Introduction
This document describes the first assignment for Problem Solving and Programming.
The assignment is intended to provide you with the opportunity to put into practice what you have learnt in the course by applying your knowledge and skills to implement a game of Blackjack.
This document is a kind of specification of the required end product that will be generated by implementing the assignment. Like many specifications, it is written in English and hence will contain some imperfectly specified parts. Please make sure you seek clarification if you are not clear on any aspect of this assignment.
Assignment Overview
You are required to write a Python program that allows a player to play a game of Blackjack against the computer. The program will allow a player to play as many games of Blackjack as they wish.
Blackjack
Blackjack is a popular card game where the goal is to beat the dealer by having the higher hand which does not exceed 21. https://en.wikipedia.org/wiki…
Although there are many variations of the rules and game play, we will be adhering to the following rules and game play for the assignment.
Blackjack hands are scored by their point total, calculated by adding together the face values of each card dealt. The hand with the highest total wins, as long as it doesn’t exceed 21. A hand with a higher total than 21 is said to bust. Being dealt an Ace (of any suit) counts as eleven (11) points unless this would cause the player to bust, in which case it is worth one (1) point. Picture cards (King, Queen and Jack) are all worth 10 points. All other cards are worth their numerical value shown on the card.
Blackjack game play:
To begin, the player and the dealer are dealt an initial hand of two cards each.
If the dealer has Blackjack (the first two cards dealt total 21 points) and the player does not, the dealer automatically wins.
If the player has Blackjack (the first two cards dealt total 21 points) and the dealer does not, the player automatically wins.
If both the player and the dealer have Blackjack (the first two cards dealt total 21 points) then it is a push (draw).
If neither have Blackjack, then the player plays out his/her hand. Note that the term Blackjack can only be achieved as a result of the first two cards dealt.
When the player has finished playing out his/her hand, the dealer (in this case the computer) plays out the dealer’s hand.
During the player’s turn, the player is faced with two options either:
1.Hit (take a card):
After the initial deal of two cards, a player may choose to receive additional cards as many times as he/she wishes, adding the point value of each card to his/her hand total.
2.Stand (end their turn):
Do not receive any more cards. The player’s turn is over.
The player repeatedly takes a card until, the player chooses to stand, or the player busts (that is, exceeds a total of 21). The player’s turn is over after deciding to stand or if he/she busts.
Once the player has finished, the dealer plays out his/her hand (in this case the computer), revealing the hidden second card amount. Note: the dealer always plays his/her hand regardless of what happens with the player’s hand. The dealer must hit until he or she has a point value of 17 or greater.
Blackjack rules:
If the player busts, he/she loses even if the dealer also busts.
If the player and the dealer have the same point value, it is called a‘push’and neither win the hand (draw).
An initial two-card deal of 21 (an 11 plus a 10) is called Blackjack (i.e. an 11 plus a 10 is dealt as the very first hand) and wins the round automatically.
An Ace counts as eleven (11) points unless this would cause the player/dealer to bust, in which case it is worth one (1) point.
House rules:
The dealer must hit until he or she has a point value of 17 or greater.
The player can not stand on a point value less than 15.
The player with the higher hand that does not exceed 21 wins the game!
You do not have to write the code that deals one card at a time, a module containing the function that does that for you has been provided. The playing_cards.py file is a module that contains a function called deal_one_card() that deals one card at a time for you. The function returns a string (containing two characters) that represents a card; the first letter represents the face value of the card and the second letter represents the suit. For example: it may return the two character string‘AH’, where‘A’represents Ace and‘H’represents Hearts;‘TC’, where‘T’represents Ten and‘C’represents Clubs,‘7S’, where‘7’represents the card value of 7 and‘S’represents Spades, etc. You are required to use this as part of this assignment, however, please do not modify the playing_cards.py file. There are other functions within the module that create the playing deck, and shuffle it, but you do not have to worry about those functions, you only have to make use of the deal_one_card() function in your solution, the other functions will take care of the rest for you! :)
Practical Requirements
It is recommended that you develop this assignment in the suggested stages.
It is expected that your solution MUST include the use of the following:
Your solution in a file called your_email_id.py.
The supplied playing_cards.py module (containing the deal_one_card() function). This is provided for you – please DO NOT modify this file.
The deal_one_card() function (provided in the supplied playing_cards.py module).
Appropriate and well constructed while and/or for loops (as necessary).
Appropriate if, if-else, if-elif-else statements (as necessary).
List of strings to represent the player’s hand, i.e. player_hand = []
List of strings to represent the dealer’s hand, i.e. dealer_hand = []
Practical requirements (continued)… Your solution MUST include the use of the following:
The following functions:
odisplay_details()
This function takes no parameters and does not return any values. The function displays your details to the screen. Remember that defining the function does not execute the function – you will need to call the function from the appropriate place in the program. Your function should produce the following output (with your details) to the screen:
File : wayby001.py
Author : Batman
Stud ID : 0123456X
Email ID : wayby001
This is my own work as defined by the University’s Academic Misconduct Policy.
oget_hit_choice()
This function takes no parameters and returns the user’s choice, whether to hit (‘h) or stand (‘s). The function prompts for, reads and validates the user’s choice to either hit or stand.
oget_play_choice(prompt_text)
This function takes a string (the prompt text) to display to the screen as a parameter and returns the users choice, whether to play again, i.e.‘y’or‘n’. The function prompts for, reads and validates the user’s choice to keep playing (‘y’) or stop playing (‘n’).
odiplay_hand(hand_text, hand)
This function takes a string (hand text) to display to the screen and a list of strings (hand) containing the cards dealt. The function does not return any values and displays the hand (list) to the screen in the following format, for example:
If the player_hand list is as follows,
player_hand = [‘4D’, ‘TS’, ‘KD’]
calling the display_hand() function like so
display_hand(‘\nPlayer\’s hand is’, player_hand)
will produce the following output to the screen:
Player’s hand is 24: 4 of Diamonds | 10 of Spades | K of Diamonds
If the dealer_hand list is as follows,
dealer_hand = [‘KS’, ‘9C’]
calling the display_hand()function like so
display_hand(‘\nDealer\’s hand is’, dealer_hand)
will produce the following output to the screen:
Dealer’s hand is 19: K of Spades | 9 of Clubs
This function must call function get_hand_total(hand).
oget_hand_total(hand)
This function takes a list of strings (containing the cards dealt) and calculates the point value of the hand. The function returns the total point value of the hand.
oplay_player_hand(player_hand)
This function takes a list of strings (containing the cards dealt) and returns the total point value of the player’s hand. The function plays out the player’s hand until the player either busts or chooses to stand. Do not let the player stand on a value less than 15 and display the player busts message if the player exceeds 21. The function must call the following functions: get_hit_choice(), get_hand_total(), display_hand() and deal_one_card().
oplay_dealer_hand(dealer_hand)
This function takes a list of strings (containing the cards dealt) and returns the total point value of the dealer’s hand. The function plays out the dealer’s hand until the dealer has a point value of 17 or greater. Display the dealer busts message if the dealer exceeds 21.
The function must call the following functions: get_hand_total(), display_hand() and deal_one_card().
Output that strictly adheres to the assignment specifications. If you are not sure about these details, you should check with the‘Sample Output’provided at the end of this document.
Good programming practice:
oConsistent commenting, layout and indentation. You are to provide comments to describe: your details, program description, all variable definitions, and every significant section of code.
oMeaningful variable names.
Your solutions MUST NOT use:
break, or continue statements in your solution. Do not use the quit() or exit() functions or the break or return statements (or any other techniques) as a way to break out of loops. Doing so will result in a significant mark deduction.
PLEASE NOTE: You are reminded that you should ensure that all input and output conform to the specifications listed here; if you are not sure about these details you should check with the sample output provided at the end of this document or post a message to the discussion forum in order to seek clarification.
Please ensure that you use Python 3 (current version) in order to complete your assignments. Your programs MUST run using Python 3 (i.e. current version).
Stages
It is recommended that you develop this assignment in the suggested stages. Many problems in later stages are due to errors in early stages. Make sure you have finished and thoroughly tested each stage before continuing.
The following stages of development are recommended:
Stage 1
You will need the playing_cards.py file for this assignment. This has been provided for you. Please download this file from the course website (Assessment tab) and ensure that it is in the same directory as your yourEmailId.py file.
Test to ensure that this is working correctly by entering the following in your yourEmailId.py file:
import playing_cards
card = playing_cards.deal_one_card()
print(card)
Run the yourEmailId.py file. If this is working correctly, you should now see the following output in the Python shell when you run your program:
The function deal_one_card() returns a string (containing two characters) that represents a card; the first letter represents the face value of the card and the second letter represents the suit. For example: it may return the two character string‘AH’, where‘A’represents Ace and‘H’represents Hearts;‘TC’, where‘T’represents Ten and‘C’represents Clubs,‘7S’, where‘7’represents the card value of 7 and‘S’represents Spades, etc. In the above example, the deal_one_card() function returned 6D, where‘6’represents the card value of 6 and‘D’represents Diamonds, i.e. 6 of Diamonds.
Please note: the two character string returned from the function call to deal_one_card() may differ when you run your code – the deck is shuffled after all! :)
Also, this is for developmental purposes only, and you will need to modify and correctly position the above code.
Make sure the program runs correctly. Once you have that working, back up your program. Note: When developing software, you should always have fixed points in your development where you know your software is bug free and runs correctly.
Stage 2
To begin, the player is dealt two cards. Use the deal_one_card() function to simulate the dealing of the player’s hand. You will need to create a list to store the cards (strings of two characters) returned from the call to function deal_one_card(), i.e. player_hand = []. You may use the append() method in order to add cards to the player_hand list (as seen below). Display the player_hand (list containing the two cards) to the screen.
import playing_cards
player_hand = []
Deal first card
card = playing_cards.deal_one_card()
Append it to the player_hand list
player_hand.append(card)
Deal second card
card = playing_cards.deal_one_card()
Append it to the player_hand list
player_hand.append(card)
Display the player’s hand to the screen using a simple print statement
print(player_hand)
Sample output:
[‘4C’, ‘2H’]
The above is displayed for testing purposes only. Eventually, when you know your code is working correctly, the player’s hand will be displayed as follows:
Sample output:
Player’s hand is 6: 4 of Clubs | 2 of Hearts
Stage 3
To begin, the dealer is also dealt two cards. Use the deal_one_card() function to simulate the dealing of the dealer’s hand. You will need to create a list to store the cards (strings of two characters) returned from the call to function deal_one_card(), i.e. dealer_hand = []. You may use the append() method in order to add cards to the dealer_hand list. Display the dealer_hand (list containing the two cards) to the screen.
Sample output:
[‘7S’, ‘5D’]
The above is displayed for testing purposes only. Eventually, when you know your code is working correctly, the dealer’s hand will be displayed as follows:
Sample output:
Dealer’s hand is 12: 7 of Spades | 5 of Diamonds
Stage 4
Implement the function called get_hand_total(hand) – see description under section titled‘Practical Requirements’. Hint: Function get_hand_total(hand) should use a loop. Display the dealer’s hand and the player’s hand to the screen as seen below. For example:
If the player_hand list is as follows,
player_hand = [‘KH’, ‘5C’]
calling the get_hand_total(hand) function like so
player_total = get_hand_total(player_hand)
will assign the value of 15 to variable player_total.
If the dealer_hand list is as follows,
dealer_hand = [‘TC’, ‘7H’]
calling the get_hand_total(hand)function like so
dealer_total = get_hand_total(dealer_hand)
will assign the value of 17 to variable dealer_total.
You can then use a simple print statement to display the player and dealer hand totals along with the lists to the screen as follows:
Sample output:
Dealer hand is: 17 [‘TC’, ‘7H’]
Player hand is: 15 [‘KH’, ‘5C’]
The above is displayed for testing purposes only. Eventually, when you know your code is working correctly, the dealer and player hands will be displayed as follows:
Sample output:
Dealer’s hand is 17: 10 of Clubs | 7 of Hearts
Player’s hand is 15: K of Hearts | 5 of Clubs
Stage 5
Implement the function called display_hand(hand_text, hand) – see description under section titled‘Practical Requirements’. Hint: Function display_hand(hand_text, hand) should use a loop and call the get_hand_total() function. Display the dealer’s hand and the player’s hand to the screen as seen below. For example:
If the player_hand list is as follows,
player_hand = [‘4D’, ‘TS’, ‘KD’]
calling the display_hand() function like so
display_hand(‘\nPlayer\’s hand is’, player_hand)
will produce the following output to the screen:
Player’s hand is 24: 4 of Diamonds | 10 of Spades | K of Diamonds
If the dealer_hand list is as follows,
dealer_hand = [‘KS’, ‘9C’]
calling the display_hand()function like so
display_hand(‘\nDealer\’s hand is’, dealer_hand)
will produce the following output to the screen:
Dealer’s hand is 19: K of Spades | 9 of Clubs
Stage 6
Include code to check for Blackjack on the initial deal of two cards for both the player and dealer.
If the dealer has Blackjack (the first two cards dealt total 21 points) and the player does not, the dealer automatically wins.
If the player has Blackjack (the first two cards dealt total 21 points) and the dealer does not, the player automatically wins.
If both the player and the dealer have Blackjack (the first two cards dealt total 21 points) then it is a push (draw).
Sample output 1:
Dealer’s hand is 10: Q of Diamonds
Player’s hand is 15: 5 of Hearts | J of Diamonds
Dealer’s hand is 21: Q of Diamonds | A of Hearts
Blackjack! Dealer Wins!
Sample output 2:
Dealer’s hand is 4: 4 of Hearts
Player’s hand is 21: A of Clubs | Q of Clubs
Blackjack! Player Wins!
Sample output 3:
Dealer’s hand is 11: A of Clubs
Player’s hand is 21: K of Hearts | A of Diamonds
* Blackjack —
Dealer’s hand is 21: A of Clubs | J of Spades
Player’s hand is 21: K of Hearts | A of Diamonds
Blackjack! Push – no winners!
Sample output 4:
Dealer’s hand is 10: J of Diamonds
Player’s hand is 17: 7 of Clubs | K of Diamonds
Play out player’s hand… coming soon… :)
If neither have Blackjack, then the player plays out his/her hand – don’t implement this just yet, simply display a message to the screen (as seen above in sample output 4).
Stage 7
Okay, now let’s include code to play out the player’s hand. Prompt for and read whether the player would like to hit (‘h’) or stand (‘s’). Implement a loop which continues to simulate one card being dealt until the user enters stand (‘s’). Display the player’s hand and the total hand value to the screen as seen below.
Sample output:
Dealer’s hand is 10: Q of Diamonds
Player’s hand is 18: A of Diamonds | 7 of Clubs
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 22: A of Diamonds | 7 of Clubs | 4 of Spades
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 27: A of Diamonds | 7 of Clubs | 4 of Spades | 5 of Hearts
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 29: A of Diamonds | 7 of Clubs | 4 of Spades | 5 of Hearts | 2 of Spades
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 38: A of Diamonds | 7 of Clubs | 4 of Spades | 5 of Hearts | 2 of Spades | 9 of Diamonds
Please enter h or s (h = Hit, s = Stand): s
You may like to implement the function called play_player_hand() at this point or you may like to come back to it once you have the player playing out his/her hand correctly – the decision is yours.
Stage 8
It does not make sense to continue rolling when the player busts (exceeds 21). Modify the loop developed in the previous stage so that it also stops looping if the player busts (exceeds 21).
Sample output:
Dealer’s hand is 4: 4 of Diamonds
Player’s hand is 11: 5 of Clubs | 6 of Hearts
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 13: 5 of Clubs | 6 of Hearts | 2 of Clubs
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 19: 5 of Clubs | 6 of Hearts | 2 of Clubs | 6 of Clubs
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 29: 5 of Clubs | 6 of Hearts | 2 of Clubs | 6 of Clubs | 10 of Clubs
–> Player busts!
Stage 9
Now let’s add a loop which simulates the computer’s turn. That is, plays out the dealer’s (computer’s) hand.
Sample output 1:
Dealer’s hand is 10: 10 of Diamonds
Player’s hand is 9: 2 of Diamonds | 7 of Diamonds
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 11: 2 of Diamonds | 7 of Diamonds | 2 of Clubs
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 20: 2 of Diamonds | 7 of Diamonds | 2 of Clubs | 9 of Diamonds
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 20: 10 of Diamonds | J of Diamonds
Sample output 2:
Dealer’s hand is 4: 4 of Clubs
Player’s hand is 9: 3 of Spades | 6 of Diamonds
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 15: 3 of Spades | 6 of Diamonds | 6 of Clubs
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 17: 3 of Spades | 6 of Diamonds | 6 of Clubs | 2 of Hearts
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 14: 4 of Clubs | K of Clubs
Dealer’s hand is 24: 4 of Clubs | K of Clubs | J of Spades
–> Dealer busts!
You may like to implement the function called play_dealer_hand() at this point or you may like to come back to it once you have the dealer playing out his/her hand correctly – the decision is yours.
Stage 10
Add code which determines the winner and displays the result to the screen.
Sample output 1:
Dealer’s hand is 10: K of Hearts
Player’s hand is 20: A of Clubs | 9 of Diamonds
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 20: K of Hearts | 10 of Hearts
— Dealer: 20 Player: 20 -> Push – no winners! —
Sample output 2:
Dealer’s hand is 10: K of Spades
Player’s hand is 16: Q of Diamonds | 6 of Clubs
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 20: K of Spades | Q of Hearts
— Dealer: 20 Player: 16 -> Dealer Wins! —
Sample output 3:
Dealer’s hand is 11: A of Spades
Player’s hand is 11: 6 of Diamonds | 5 of Diamonds
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 19: 6 of Diamonds | 5 of Diamonds | 8 of Diamonds
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 14: A of Spades | 3 of Diamonds
Dealer’s hand is 17: A of Spades | 3 of Diamonds | 3 of Hearts
— Dealer: 17 Player: 19 -> Player Wins! —
Stage 11
Add code that ensures that the player can not stand (‘s’) on a hand value of less than 15. Notice that the player automatically rolls again when this happens (see sample output below).
Sample output:
Dealer’s hand is 10: Q of Diamonds
Player’s hand is 14: 7 of Spades | 7 of Diamonds
Please enter h or s (h = Hit, s = Stand): s
Cannot stand on value less than 15!
Player’s hand is 24: 7 of Spades | 7 of Diamonds | J of Hearts
–> Player busts!
Dealer’s hand is 19: Q of Diamonds | 9 of Clubs
— Dealer: 19 Player: 24 -> Dealer Wins! —
Stage 12
Add yet another loop that asks the player whether they wish to play again [‘y’|’n’].
Stage 13
Add code to keep track of how many games were played, how many were won, lost and drawn. Display this to the screen.
Stage 14
Add code to validate all user input. Hint: use a while loop to validate input. Implement the following functions:
oget_hit_choice()
This function takes no parameters and returns the user’s choice, whether to hit (‘h) or stand (‘s). The function prompts for, reads and validates the user’s choice to either hit or stand.
oget_play_choice(prompt_text)
This function takes a string (the prompt text) to display to the screen as a parameter and returns the users choice, whether to play again, i.e.‘y’or‘n’. The function prompts for, reads and validates the user’s choice to keep playing (‘y’) or stop playing (‘n’).
Sample output:
Would you like to play BlackJack [y|n]? p
Would you like to play BlackJack [y|n]? t
Would you like to play BlackJack [y|n]? y
Dealer’s hand is 10: K of Diamonds
Player’s hand is 10: 3 of Diamonds | 7 of Hearts
Please enter h or s (h = Hit, s = Stand): z
Please enter h or s (h = Hit, s = Stand): j
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 13: 3 of Diamonds | 7 of Hearts | 3 of Clubs
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 23: 3 of Diamonds | 7 of Hearts | 3 of Clubs | J of Spades
–> Player busts!
Dealer’s hand is 15: K of Diamonds | 5 of Diamonds
Dealer’s hand is 25: K of Diamonds | 5 of Diamonds | K of Spades
–> Dealer busts!
— Dealer: 25 Player: 23 -> Dealer Wins! —
That was fun!
Play again [y|n]? e
Play again [y|n]? b
Play again [y|n]? n
You played 1 games!
-> Won: 0
-> Lost: 1
-> Drawn: 0
Stage 15
Finally, check the sample output (see section titled‘Sample Output’towards the end of this document) and if necessary, modify your code so that:
The output produced by your program EXACTLY adheres to the sample output provided.
Your program behaves as described in these specs and as the sample output provided.
Submission Details
You are required to do the following in order to submit your work and have it marked:
oYou are required to save your .py file(s) of Assignment 3 including all supplied files into a single zip file with file name uopsp_assignment3_username.zip, where username is your university network username / email ID (e.g. karsy028) and submit your zip file via the submission point by Monday, 07 June (Week 10), 12:00 PM (Adelaide time).
Ensure that your files are named correctly (as per instructions outlined in this document).
Ensure that the following file is included in your submission:
your_email_id.py
For example (if your name is James Bond, your submission files would be as follows):
bonjy007.py
All files that you submit must include the following comments.
File: fileName.py
Author: your name
Email Id: your email id
Description: Assignment 2 – place assignment description here…
This is my own work as defined by the University’s
Academic Misconduct policy.
Assignments that do not contain these details may not be marked.
It is expected that students will make copies of all assignments and be able to provide these if required.
Sample Output
Sample output 1:
File : wayby001.py
Author : Batman
Stud ID : 0123456X
Email ID : wayby001
This is my own work as defined by the University’s Academic Misconduct Policy.
Would you like to play BlackJack [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 3: 3 of Clubs
Player’s hand is 9: 5 of Clubs | 4 of Clubs
Please enter h or s (h = Hit, s = Stand): s
Cannot stand on value less than 15!
Player’s hand is 19: 5 of Clubs | 4 of Clubs | Q of Clubs
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 14: 3 of Clubs | A of Clubs
Dealer’s hand is 20: 3 of Clubs | A of Clubs | 6 of Hearts
— Dealer: 20 Player: 19 -> Dealer Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 4: 4 of Hearts
Player’s hand is 20: K of Diamonds | J of Hearts
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 9: 4 of Hearts | 5 of Hearts
Dealer’s hand is 19: 4 of Hearts | 5 of Hearts | J of Diamonds
— Dealer: 19 Player: 20 -> Player Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 4: 4 of Diamonds
Player’s hand is 15: 4 of Spades | A of Spades
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 25: 4 of Spades | A of Spades | Q of Diamonds
–> Player busts!
Dealer’s hand is 15: 4 of Diamonds | A of Hearts
Dealer’s hand is 17: 4 of Diamonds | A of Hearts | 2 of Spades
— Dealer: 17 Player: 25 -> Dealer Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 10: Q of Spades
Player’s hand is 20: J of Spades | 10 of Clubs
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 17: Q of Spades | 7 of Diamonds
— Dealer: 17 Player: 20 -> Player Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 2: 2 of Hearts
Player’s hand is 15: J of Clubs | 5 of Spades
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 21: J of Clubs | 5 of Spades | 6 of Spades
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 12: 2 of Hearts | Q of Hearts
Dealer’s hand is 22: 2 of Hearts | Q of Hearts | 10 of Diamonds
–> Dealer busts!
— Dealer: 22 Player: 21 -> Player Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? n
You played 5 games!
-> Won: 3
-> Lost: 2
-> Drawn: 0
Thanks for playing! :)
Sample output 2:
File : wayby001.py
Author : Batman
Stud ID : 0123456X
Email ID : wayby001
This is my own work as defined by the University’s Academic Misconduct Policy.
Would you like to play BlackJack [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 4: 4 of Clubs
Player’s hand is 9: 6 of Clubs | 3 of Spades
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 19: 6 of Clubs | 3 of Spades | Q of Hearts
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 9: 4 of Clubs | 5 of Hearts
Dealer’s hand is 17: 4 of Clubs | 5 of Hearts | 8 of Clubs
— Dealer: 17 Player: 19 -> Player Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 10: Q of Clubs
Player’s hand is 12: A of Hearts | A of Diamonds
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 20: A of Hearts | A of Diamonds | 8 of Spades
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 12: Q of Clubs | 2 of Spades
Dealer’s hand is 15: Q of Clubs | 2 of Spades | 3 of Clubs
Dealer’s hand is 25: Q of Clubs | 2 of Spades | 3 of Clubs | K of Hearts
–> Dealer busts!
— Dealer: 25 Player: 20 -> Player Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? n
You played 2 games!
-> Won: 2
-> Lost: 0
-> Drawn: 0
Thanks for playing! :)
Sample output 3:
File : wayby001.py
Author : Batman
Stud ID : 0123456X
Email ID : wayby001
This is my own work as defined by the University’s Academic Misconduct Policy.
Would you like to play BlackJack [y|n]? p
Would you like to play BlackJack [y|n]? t
Would you like to play BlackJack [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 7: 7 of Diamonds
Player’s hand is 15: 4 of Spades | A of Hearts
Please enter h or s (h = Hit, s = Stand): o
Please enter h or s (h = Hit, s = Stand): y
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 22: 4 of Spades | A of Hearts | 7 of Clubs
–> Player busts!
Dealer’s hand is 17: 7 of Diamonds | 10 of Diamonds
— Dealer: 17 Player: 22 -> Dealer Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? z
Play again [y|n]? w
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 10: 10 of Hearts
Player’s hand is 20: K of Spades | 10 of Spades
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 16: 10 of Hearts | 6 of Spades
Dealer’s hand is 26: 10 of Hearts | 6 of Spades | K of Diamonds
–> Dealer busts!
— Dealer: 26 Player: 20 -> Player Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 2: 2 of Diamonds
Player’s hand is 18: 8 of Hearts | J of Clubs
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 23: 8 of Hearts | J of Clubs | 5 of Clubs
–> Player busts!
Dealer’s hand is 13: 2 of Diamonds | A of Diamonds
Dealer’s hand is 17: 2 of Diamonds | A of Diamonds | 4 of Clubs
— Dealer: 17 Player: 23 -> Dealer Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 8: 8 of Diamonds
Player’s hand is 18: Q of Diamonds | 8 of Clubs
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 28: Q of Diamonds | 8 of Clubs | Q of Spades
–> Player busts!
Dealer’s hand is 14: 8 of Diamonds | 6 of Diamonds
Dealer’s hand is 24: 8 of Diamonds | 6 of Diamonds | J of Spades
–> Dealer busts!
— Dealer: 24 Player: 28 -> Dealer Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? n
You played 4 games!
-> Won: 1
-> Lost: 3
-> Drawn: 0
Thanks for playing! :)
Sample output 4:
File : wayby001.py
Author : Batman
Stud ID : 0123456X
Email ID : wayby001
This is my own work as defined by the University’s Academic Misconduct Policy.
Would you like to play BlackJack [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 9: 9 of Clubs
Player’s hand is 21: Q of Diamonds | A of Spades
Blackjack! Player Wins!
———————– END GAME ———————–
That was fun!
Play again [y|n]? n
You played 1 games!
-> Won: 1
-> Lost: 0
-> Drawn: 0
Thanks for playing! :)
Sample output 5:
File : wayby001.py
Author : Batman
Stud ID : 0123456X
Email ID : wayby001
This is my own work as defined by the University’s Academic Misconduct Policy.
Would you like to play BlackJack [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 11: A of Hearts
Player’s hand is 20: Q of Hearts | J of Clubs
Dealer’s hand is 21: A of Hearts | J of Spades
Blackjack! Dealer Wins!
———————– END GAME ———————–
That was fun!
Play again [y|n]? n
You played 1 games!
-> Won: 0
-> Lost: 1
-> Drawn: 0
Thanks for playing! :)
Sample output 6:
File : wayby001.py
Author : Batman
Stud ID : 0123456X
Email ID : wayby001
This is my own work as defined by the University’s Academic Misconduct Policy.
Would you like to play BlackJack [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 11: A of Hearts
Player’s hand is 21: K of Clubs | A of Diamonds
* Blackjack —
Dealer’s hand is 21: A of Hearts | J of Spades
Player’s hand is 21: K of Clubs | A of Diamonds
Blackjack! Push – no winners!
———————– END GAME ———————–
That was fun!
Play again [y|n]? n
You played 1 games!
-> Won: 0
-> Lost: 0
-> Drawn: 1
Thanks for playing! :)
Sample output 7:
File : wayby001.py
Author : Batman
Stud ID : 0123456X
Email ID : wayby001
This is my own work as defined by the University’s Academic Misconduct Policy.
Would you like to play BlackJack [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 3: 3 of Hearts
Player’s hand is 14: 4 of Spades | J of Spades
Please enter h or s (h = Hit, s = Stand): s
Cannot stand on value less than 15!
Player’s hand is 15: 4 of Spades | J of Spades | A of Hearts
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 25: 4 of Spades | J of Spades | A of Hearts | K of Spades
–> Player busts!
Dealer’s hand is 6: 3 of Hearts | 3 of Diamonds
Dealer’s hand is 17: 3 of Hearts | 3 of Diamonds | A of Clubs
— Dealer: 17 Player: 25 -> Dealer Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 10: 10 of Spades
Player’s hand is 10: 5 of Diamonds | 5 of Clubs
Please enter h or s (h = Hit, s = Stand): s
Cannot stand on value less than 15!
Player’s hand is 20: 5 of Diamonds | 5 of Clubs | Q of Clubs
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 20: 10 of Spades | K of Diamonds
— Dealer: 20 Player: 20 -> Push – no winners! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? n
You played 2 games!
-> Won: 0
-> Lost: 1
-> Drawn: 1
Thanks for playing! :)
Sample output 8:
File : wayby001.py
Author : Batman
Stud ID : 0123456X
Email ID : wayby001
This is my own work as defined by the University’s Academic Misconduct Policy.
Would you like to play BlackJack [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 6: 6 of Clubs
Player’s hand is 14: 10 of Diamonds | 4 of Clubs
Please enter h or s (h = Hit, s = Stand): s
Cannot stand on value less than 15!
Player’s hand is 19: 10 of Diamonds | 4 of Clubs | 5 of Spades
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 13: 6 of Clubs | 7 of Diamonds
Dealer’s hand is 23: 6 of Clubs | 7 of Diamonds | K of Clubs
–> Dealer busts!
— Dealer: 23 Player: 19 -> Player Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 11: A of Hearts
Player’s hand is 15: 9 of Spades | 6 of Spades
Dealer’s hand is 21: A of Hearts | Q of Hearts
Blackjack! Dealer Wins!
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 11: A of Spades
Player’s hand is 21: Q of Spades | A of Diamonds
* Blackjack —
Dealer’s hand is 21: A of Spades | Q of Diamonds
Player’s hand is 21: Q of Spades | A of Diamonds
Blackjack! Push – no winners!
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 2: 2 of Spades
Player’s hand is 10: 7 of Spades | 3 of Spades
Please enter h or s (h = Hit, s = Stand): s
Cannot stand on value less than 15!
Player’s hand is 14: 7 of Spades | 3 of Spades | 4 of Hearts
Please enter h or s (h = Hit, s = Stand): s
Cannot stand on value less than 15!
Player’s hand is 20: 7 of Spades | 3 of Spades | 4 of Hearts | 6 of Diamonds
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 12: 2 of Spades | K of Spades
Dealer’s hand is 15: 2 of Spades | K of Spades | 3 of Hearts
Dealer’s hand is 16: 2 of Spades | K of Spades | 3 of Hearts | A of Clubs
Dealer’s hand is 23: 2 of Spades | K of Spades | 3 of Hearts | A of Clubs | 7 of Hearts
–> Dealer busts!
— Dealer: 23 Player: 20 -> Player Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? n
You played 4 games!
-> Won: 2
-> Lost: 1
-> Drawn: 1
Thanks for playing! :)
Sample output 9:
File : wayby001.py
Author : Batman
Stud ID : 0123456X
Email ID : wayby001
This is my own work as defined by the University’s Academic Misconduct Policy.
Would you like to play BlackJack [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 11: A of Hearts
Player’s hand is 17: 7 of Spades | 10 of Hearts
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 18: A of Hearts | 7 of Hearts
— Dealer: 18 Player: 17 -> Dealer Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 9: 9 of Spades
Player’s hand is 10: 7 of Diamonds | 3 of Spades
Please enter h or s (h = Hit, s = Stand): s
Cannot stand on value less than 15!
Player’s hand is 19: 7 of Diamonds | 3 of Spades | 9 of Clubs
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 19: 9 of Spades | K of Spades
— Dealer: 19 Player: 19 -> Push – no winners! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 3: 3 of Clubs
Player’s hand is 16: 6 of Spades | J of Spades
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 22: 6 of Spades | J of Spades | 6 of Diamonds
–> Player busts!
Dealer’s hand is 13: 3 of Clubs | 10 of Spades
Dealer’s hand is 23: 3 of Clubs | 10 of Spades | 10 of Clubs
–> Dealer busts!
— Dealer: 23 Player: 22 -> Dealer Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 8: 8 of Diamonds
Player’s hand is 18: 8 of Clubs | Q of Spades
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 14: 8 of Diamonds | 6 of Hearts
Dealer’s hand is 15: 8 of Diamonds | 6 of Hearts | A of Spades
Dealer’s hand is 25: 8 of Diamonds | 6 of Hearts | A of Spades | J of Hearts
–> Dealer busts!
— Dealer: 25 Player: 18 -> Player Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? h
Play again [y|n]? n
You played 4 games!
-> Won: 1
-> Lost: 2
-> Drawn: 1
Thanks for playing! :)
Sample output 10:
File : wayby001.py
Author : Batman
Stud ID : 0123456X
Email ID : wayby001
This is my own work as defined by the University’s Academic Misconduct Policy.
Would you like to play BlackJack [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 3: 3 of Spades
Player’s hand is 20: Q of Diamonds | 10 of Clubs
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 11: 3 of Spades | 8 of Diamonds
Dealer’s hand is 12: 3 of Spades | 8 of Diamonds | A of Clubs
Dealer’s hand is 17: 3 of Spades | 8 of Diamonds | A of Clubs | 5 of Diamonds
— Dealer: 17 Player: 20 -> Player Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 3: 3 of Clubs
Player’s hand is 19: 9 of Clubs | Q of Spades
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 8: 3 of Clubs | 5 of Hearts
Dealer’s hand is 18: 3 of Clubs | 5 of Hearts | 10 of Spades
— Dealer: 18 Player: 19 -> Player Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 9: 9 of Spades
Player’s hand is 11: 9 of Hearts | 2 of Spades
Please enter h or s (h = Hit, s = Stand): s
Cannot stand on value less than 15!
Player’s hand is 16: 9 of Hearts | 2 of Spades | 5 of Spades
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 13: 9 of Spades | 4 of Spades
Dealer’s hand is 19: 9 of Spades | 4 of Spades | 6 of Spades
— Dealer: 19 Player: 16 -> Dealer Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? n
You played 3 games!
-> Won: 2
-> Lost: 1
-> Drawn: 0
Thanks for playing! :)
Sample output 11:
File : wayby001.py
Author : Batman
Stud ID : 0123456X
Email ID : wayby001
This is my own work as defined by the University’s Academic Misconduct Policy.
Would you like to play BlackJack [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 3: 3 of Spades
Player’s hand is 13: 3 of Clubs | 10 of Clubs
Please enter h or s (h = Hit, s = Stand): s
Cannot stand on value less than 15!
Player’s hand is 21: 3 of Clubs | 10 of Clubs | 8 of Diamonds
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 13: 3 of Spades | J of Spades
Dealer’s hand is 18: 3 of Spades | J of Spades | 5 of Clubs
— Dealer: 18 Player: 21 -> Player Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? n
You played 1 games!
-> Won: 1
-> Lost: 0
-> Drawn: 0
Thanks for playing! :)
Sample output 12:
File : wayby001.py
Author : Batman
Stud ID : 0123456X
Email ID : wayby001
This is my own work as defined by the University’s Academic Misconduct Policy.
Would you like to play BlackJack [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 9: 9 of Clubs
Player’s hand is 4: 2 of Hearts | 2 of Clubs
Please enter h or s (h = Hit, s = Stand): s
Cannot stand on value less than 15!
Player’s hand is 9: 2 of Hearts | 2 of Clubs | 5 of Spades
Please enter h or s (h = Hit, s = Stand): s
Cannot stand on value less than 15!
Player’s hand is 19: 2 of Hearts | 2 of Clubs | 5 of Spades | J of Clubs
Please enter h or s (h = Hit, s = Stand): s
Dealer’s hand is 19: 9 of Clubs | 10 of Hearts
— Dealer: 19 Player: 19 -> Push – no winners! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? n
You played 1 games!
-> Won: 0
-> Lost: 0
-> Drawn: 1
Thanks for playing! :)
Sample output 13:
File : wayby001.py
Author : Batman
Stud ID : 0123456X
Email ID : wayby001
This is my own work as defined by the University’s Academic Misconduct Policy.
Would you like to play BlackJack [y|n]? y
———————- START GAME ———————-
Dealer’s hand is 7: 7 of Clubs
Player’s hand is 6: 2 of Clubs | 4 of Diamonds
Please enter h or s (h = Hit, s = Stand): s
Cannot stand on value less than 15!
Player’s hand is 14: 2 of Clubs | 4 of Diamonds | 8 of Spades
Please enter h or s (h = Hit, s = Stand): h
Player’s hand is 24: 2 of Clubs | 4 of Diamonds | 8 of Spades | J of Hearts
–> Player busts!
Dealer’s hand is 17: 7 of Clubs | K of Spades
— Dealer: 17 Player: 24 -> Dealer Wins! —
———————– END GAME ———————–
That was fun!
Play again [y|n]? n
You played 1 games!
-> Won: 0
-> Lost: 1
-> Drawn: 0
Thanks for playing! :)
WX:codehelp