Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

as user enters 'hit' i want the program to add another random number (generated from the fog() function) but the new numbers keep chnaging as

image text in transcribed
image text in transcribed
image text in transcribedas user enters 'hit' i want the program to add another random number (generated from the fog() function) but the new numbers keep chnaging as i enter hit.
this is my goal:
the 2 given numbers are: 2,4
and if user enters hit it chnages it to 2,4,6
and if user enter hit again it should say 2,4,6,7
but in my program the new random numbers keep changing, is there a way to get around this ?
image text in transcribed
my python program:
def play():
x = 0
c = ['2','3','4','5','6','7','8','9','J','Q','K','A']
a = random.choice(c)
print(a)
if a == '2' or a == '3' or a == '4' or a == '5' or a == '6' or a == '7' or a == '8' or a == '9':
x = int(a)
elif a == 'K' or a == 'J' or a == 'Q':
x = 10
x = int(x)
elif a == 'A':
one = random.randint(1,2)
if one == 2:
x = 11
x = int(x)
else:
x = 1
x = int(x)
y = 0
d = ['2','3','4','5','6','7','8','9','J','Q','','A']
b = random.choice(d)
print(b)
if b == '2' or b == '3' or b == '4' or b == '5' or b == '6' or b == '7' or b == '8' or b == '9':
y = int(b)
elif b == 'K' or b == 'J' or b == 'Q':
y = 10
y = int(y)
elif b == 'A':
one = random.randint(1,2)
if one == 2:
y = 11
y = int(y)
else:
y = 1
y = int(y)
print(x+y)
loser = 0
more = 0
while loser
ask = input("Hit or stand? ")
if ask == 'hit':
more += 1
if more == 1:
loser = x+y+fog()
print(f"Your current hand: {x} {y} {fog()} {loser}")
if more == 2:
loser = x+y+fog()+fog()
print(f"Your current hand: {x} {y} {fog()} {fog()} {loser}")
elif ask == 'stand':
break
def fog():
score = 0
x = 0
c = ['2','3','4','5','6','7','8','9','J','Q','K','A']
a = random.choice(c)
if a == '2' or a == '3' or a == '4' or a == '5' or a == '6' or a == '7' or a == '8' or a == '9':
x = int(a)
if a == 'K' or a == 'J' or a == 'Q':
x = 10
x = int(x)
elif a == 'A':
one = random.randint(1,2)
if one == 2:
x = 11
x = int(x)
else:
x = 1
x = int(x)
return x
play()
ription invite 8+ run main.py saved 1 import random def play(); c = ('2','3', '4', '5', '6', '7', '8', '9','3','0', 'K', 'A') a = random.choice(c) print(a) if a = '2' or a == '3' or a == '4' or a = or a = '6' or a == '7' or a == '8' or a = x = int(a) '5' '9': 'D': elif a = 'K' or a == 'J' or a - x = 10 x = int(x) elif a ='A': one = random.randint(1,2) if one == 2: x = 11 x = int(x) else: X = 1 x = int(x) MacBook Pro VILCA FUR saved main.py y = @ d = ('2', '3', '4', '5', '6', '7', '8', '9', 'J','0',', 'A') b = random.choice(d) print(b) if b = '2' or b = or b = '6' or b = | y = int(b) '3' or b = '7' or b = '4' or b = 'g' or b = '5', '9': '0': 36 al elif b = 'K' or b = 'j' or b = y = 10 y = int(y) elif b = 'A': one = random.randint(1,2) 41 if one = 2: y = 11 y = int(y) else: y = 1 y = int(y) print(x+y) loser = @ more = @ po MacBook Pro W e ton Centre Outlook a Amazon y Twitter Culoarx em/blacljack2 ion invite 8+ run 47 main.py saved UTY - 4111: print(x+y) loser = more = while loser = 21: ask = input("Hit or stand?") if ask = 'hit': more t= 1 if more = 1: Loser = x+y+fog() print(f"Your current_hand: {x} {y} {fog()} {loser}") if more = 2: Loser = x+y+fog()+fog() print(f"Your current hand: {x} {y} {fog()} {fog(} {loser}") elif ask = 'stand': 62 E N break e def fog(): score = @ 70 MacBook Pro main.py saved c = ('2', '3', '4', '5', '6', '7', '8', '9','3','0', 'K', 'A') a = random.choice(c) if a = or a = '2' or a = '6' or a = '3' or a = '7' or a = '4' or a = '5', 'g' or a = '9': x = int(a) 80 E 'Q'! if a = 'K' or a = 'j' or a x = 10 x = int(x) elif a = 'A': one = random.randint(1,2) if one = 2: x = 11 x = int(x) else: X = 1 x = int(x) return x play() 94 MacBook Pro

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_2

Step: 3

blur-text-image_3

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

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

More Books

Students also viewed these Databases questions

Question

2 What does the term organisation culture mean?

Answered: 1 week ago