Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python 1. The blackjack application developed in Case Study CS.6 includes the dealCard() function that pops the top card from the deck and passes

Using Python

1. The blackjack application developed in Case Study CS.6 includes the dealCard() function that pops the top card from the deck and passes it to a game participant. The deck is implemented as a list of cards, and popping the top card from the deck corresponds to popping the list. If the function is called on an empty deck, an attempt to pop an empty list is made, and an IndexError exception is raised. Modify the blackjack application by handling the exception raised when trying to deal a card from an empty deck. Your handler should create a new shuffled deck and deal a card from the top of this new deck.

2. 7.20 In Problem 7.19, the program quits only when the user makes two mistakes in a row. Implement the alternative version of the program that quits when the user makes the second mistake, even if it follows a correct entry by the user.

--- Previous Problem----

def InValues():

count=1;

lst=[];

while True:

try: m=raw_input("Pls enter a number : ")

if m=='0':

total=sum(lst);

print total;

break;

n=float(m);

lst.append(n);

except ValueError:

count=count+1;

if(count>2):

print ("Two errors in a row, Quiting !!!");

break;

else: print ("Error,Pls re-enter the value.");

InValues()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions