Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

COSI 10a (Spring, 2024)

Introduction to Problem Solving in Python

Due: Friday, 1 March 2024

Programming Assignment #3

Program Description

This assignment will be due at 11pm on Friday, 1st of March.

Blackjack is a game where the goal is to build a hand of cards with a point value that is as close to 21 as possible, without ever being greater than 21. The game is played in rounds in which the player has the choice to “hit” (be dealt another card) or “stand” (not be dealt another card and keep current value). In each round the player chooses to receive another card, the dealer is given another card as well. The first card the dealer receives is “face-up” (the player knows what it is), but all subsequent cards the dealer receives are not known to the player. Your game should follow the following format. This video should be helpful in understanding the process (https://www.youtube.com/watch?v=eyoh-Ku9TCI). One important   note is that there is only a single player versus the house – the user prompting the terminal.

1)   The player makes their bets before the game begins.

2)   The player and dealer each receive one face up card.

3)   All players are given one more face up card, and the dealer is given one face-down card, meaning the player cannot see the value of their second card.

4)   At this point, ifyour two face up cards equal 21 (a face card and ace), the round is over and you win. Otherwise, the round continues.

5)   The dealer will ask ifyou want to add another card to your hand. If you do, the player says “hit”, or “stand” if they want to keep their current value. The player can continue asking for cards until they stand, or until they bust (value of cards is greater than 21).

6)   If a player is happy with their card values and says “stand”, cards are then added to the dealer's hand until they are of greater value than the value of the player. You will need to reveal the hidden, face down card before continuing (note: for simplicity, we will be ignoring the <16 or >17 rule as shown in the wikiHow video), or until they bust. In the former scenario the dealer wins, and in the latter the player wins double their initial bet.

Your program should allow the player to play multiple games of blackjack in a row, until the player would like to quit.  In order to receive a pass+ (3), you will also need to implement a betting aspect of that game that keeps track of how much the player won or lost over the course of all games. For example, at the start of each round, you could ask the player how much they want to bet, and add that to a virtual wallet. If they win, no matter the scenario, it should be 2x their bet, if they lose, they will lose all in that current bet.

If implementing a betting system, start the player with $100.

You may talk to other students about the assignment and consult the slides and online resources for syntax, but all code you submit must be your own. Do not copy code directly from other students or from any online resources. The best way to not get caught plagiarizing is to not do it in the first place.

Requirements

1.   Your program must run without error and give the correct output.

2.   Your code must be commented and have descriptive function and variable names.

3.   All functions should have descriptive docstrings.

4.   There should be no code outside of a function except for a call to main(), constants, or import statements.

5.   Your code should be well structured and split into appropriate functions.

6.   Include a comment at the top of the file with your name, the assignment number, and a brief description of what the program does. For example:

#Full Name

#COSI 10a Spring 2024

#Programming Assignment 3

#Description: …

#Known bugs: 

You should limit your code to what we have learned through chapter 5.

Submission and Grading

Submit via Latte a zip file named yourfirstname_yourlastnamePA3.zip which contains your program file. To create a zip file on Mac, right click the document/folder and select the “Compress [document/folder name]” option. On Windows, right click the document/folder and select the “Send To..” and then “zip/compressed file” options. See the top of this document for the due date and time.

You may talk to other students about the assignment and consult the slides and online resources for syntax, but all code you submit must be your own. Do not copy code directly from other students or from any online resources. The best way to not get caught plagiarizing is to not do it in the first place. The graders will be receiving a solution generated by ChatGPT to see how it will utilize style – so we highly recommend not getting your answer from ChatGPT. These assignments are training your ability to deconstruct problems and process solutions in code, not to see how quickly you can solve it!

There are 3 possible grades you may receive for this assignment: fail, pass, and pass+. Your program will be graded pass/fail on each of the requirements listed above. If your code does not meet requirement (correctly named, produces the desired output without error) you will not receive an overall passing grade. Of the remaining requirements, you may fail no more than 2 to receive a passing grade. Submissions that   meet all of the requirements and implement the additional functionality described above will receive a grade of pass+.