Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Blackjack Program Using Existing Deck Code as a Base Using the following Python code as a base, create a Blackjack program that can be

Python Blackjack Program Using Existing Deck Code as a Base

Using the following Python code as a base, create a Blackjack program that can be played against the computer.

import random #create the deck of cards #s=spades, d=diamonds, c=clubs, h=hearts, a=ace, k=king, q=queen, j=jack cards = ['AS', 'KS', 'QS', 'JS', '10S', '9S', '8S', '7S', '6S', '5S', '4S', '3S', '2S',\ 'AD', 'KD', 'QD', 'JD', '10D', '9D', '8D', '7D', '6D', '5D', '4D', '3D', '2D',\ 'AC', 'KC', 'QC', 'JC', '10C', '9C', '8C', '7C', '6C', '5C', '4C', '3C', '2C',\ 'AH', 'KH', 'QH', 'JH', '10H', '9H', '8H', '7H', '6H', '5H', '4H', '3H', '2H'] #create array to hold cards that are dealt deal = [] #shuffle the cards random.shuffle(cards) num = int(input("How many cards would you like me to deal? ")) while num > 0: deal.append(cards.pop(0)) num = num - 1 print ("Your cards are: ") print (deal) print ("The cards remaining in the deck are: ") print (cards)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions