






Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Prepara tus exámenes
Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Prepara tus exámenes con los documentos que comparten otros estudiantes como tú en Docsity
Encuentra los documentos específicos para los exámenes de tu universidad
Estudia con lecciones y exámenes resueltos basados en los programas académicos de las mejores universidades
Responde a preguntas de exámenes reales y pon a prueba tu preparación
Consigue puntos base para descargar
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Comunidad
Pide ayuda a la comunidad y resuelve tus dudas de estudio
Ebooks gratuitos
Descarga nuestras guías gratuitas sobre técnicas de estudio, métodos para controlar la ansiedad y consejos para la tesis preparadas por los tutores de Docsity
Estas son las instrucciones para que resuelvas un blackjack en python
Tipo: Ejercicios
1 / 10
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!







First, congratulations on completing the course! This will be a chance for you to apply the skills you’ve learned throughout the course and get some valuable feedback from me. The game you will work to create is Blackjack! If you need a refresher on the rules you can read up here or read the short descriptions of the game provided below.
Description: Blackjack is a very popular gambling game, typically played in casinos. It involves a dealer and between 1-6 other players. For our purposes we will be playing a version of blackjack that involves one player and a dealer. Objective: Each player at the table plays alone and soles objective is to have a higher hand than the dealer without going over 21. Normally bets are placed before the round starts and each player that wins will have their bet matched by the dealer. If the player loses then the dealer will take their bet. For this version of the game we will not play with bets. Game Play: The game may contain infinite rounds. Each round starts with the dealer and each player being dealt two cards. The players cards are dealt faceup and the dealer is dealt one card face down and one face up. The player will look at their cards and choose one of two options: HIT or STAY. If the player decides to HIT, they will be given another card. If the player decides to STAY, the next player on the table will go. A player may HIT as many times as they like. However, if the value of their cards sums to greater than 21, they BUST and will loose the round. Once each player has gone the dealer will flip over their hidden card. They will then follow a set of predefined rules on whether to HIT or STAY. At the end of the dealers turn they will compare their hand to each player. If they have a higher hand and have not gone over 21 that player will loose. If the dealer has a lower hand or went over 21 then that player will win. The cards will then be reshuffled, and a new round will begin. Dealer Rules: If the value of the dealer’s cards is below 17, they must HIT, otherwise they must STAY. The dealer will HIT as many times as necessary. Card Values:
2 – 10 are valued 2 – 10 accordingly Any face cards ( Jack, Queen, King ) are valued as 10. An Ace may be used as a 1 or an 11 (whichever favours the player/dealer). The Ace may also change values as the turn progresses. For example, you get a 7 and an Ace, your card value may be 8 or 18. If you decide to HIT and receive another 7 your card value will be 15. This is because the ace acts as a one, as if it was 11 you would bust.
Here are some of the modifications we will use to simplify the game.
As listed above the deck for the game will consist of 52 cards. That is 4 suits of 13 cards. To make things simpler we will represent the suits as follows: 1: HEARTS 2: DIMAONDS 3: CLUBS 4: SPADES We will represent the ranks as follows: 01: ACE 02: TWO 03: THREE 04: FOUR 05: FIVE 06: SIX
Please download the starter code from the course website and work from that file. It is highly recommended that you only use code/syntax covered in this course
Your codes output should be as similar to this as possible. The following is copied directly from IDLE after running the program a few times. === RESTART: C:\Users\timot\OneDrive\Desktop\Course\blackjack_solutions.py === Welcome to blackjack!
Round 1 has started! The cards have been dealt... Your Cards: 413, 112. Dealers Cards: 112, hidden.
Would you like to play again (Y/N)? n
=== RESTART: C:\Users\timot\OneDrive\Desktop\Course\blackjack_solutions.py === Welcome to blackjack!
Round 1 has started! The cards have been dealt... Your Cards: 105, 308. Dealers Cards: 308, hidden. Your turn has started. Would you like to hit or stay? no Not a valid option, try again. Would you like to hit or stay? yes Not a valid option, try again. Would you like to hit or stay? hit You hit and received the card: 403 Your Cards: 105, 308, 403. Would you like to hit or stay? stay You decided to stay, your turn is over. The dealers turn has started. The dealer reveals their hidden card is a 403 Dealers Cards: 308, 403. The dealer hits and received: 408 The dealer stays.
The dealer has 19 You have 16 You lost to the dealer... Would you like to play again (Y/N)? y
Round 2 has started! The cards have been dealt... Your Cards: 106, 102. Dealers Cards: 102, hidden. Your turn has started. Would you like to hit or stay? hit You hit and received the card: 306 Your Cards: 106, 102, 306. Would you like to hit or stay? hit You hit and received the card: 410 Your Cards: 106, 102, 306, 410. You BUST and have lost this round. Would you like to play again (Y/N)? yes
Round 3 has started! The cards have been dealt... Your Cards: 308, 207.
Would you like to hit or stay? hit You hit and received the card: 312 Your Cards: 202, 210, 401, 312. You BUST and have lost this round. Would you like to play again (Y/N)? n