itasykamila
30.10.2020 •
Computers and Technology
CODE THIS IN PYTHON PLEASE I NEED HELP BADLY
Ninety-Nine is a two-player card game played with a deck of 40-cards. The cards are labeled 0 – 9. To start, each player gets 3 cards and the remaining cards are placed face
down on the table (the pile). In an actual game, the point total is set to zero but for this program, an initial point total will be given. Cards are played in the order they are added to a player’s hand. Each player in turn puts down a card and changes the point total according to the point value of his card and then selects a card from the top of the pile. Each card adds its face value in points (e.g. a 5 is worth five points) to the point total except for certain cards that have special values or meanings:
1. A 9 is a pass (and does not change point total)
2. A 4 subtracts 10 points from the total
3. A 0 adds either 1 or 11 to the point total. The 11 is played first as long as it does not put
the point total over 99.
If a player plays a card that puts the total over 99, that player loses the game.
GET THE USER TO INPUT THE CARDS AND TOTAL POINT VALUE.
INPUT:
An input line will contain 11 integers. The first integer gives the initial point total. The next 3 integers will represent the 3 cards dealt to the player. The remaining integers will be, in order, the card picked by the player and the card played by the dealer.
OUTPUT:
Print the point total when the game ends and who won (player or dealer).
SAMPLE INPUT OUTPUT
87, 5, 8, 9, 7, 4, 6, 3, 9, 0, 2 101,dealer
78, 2, 4, 8, 3, 8, 5, 0, 6, 9, 8 100,dealer
95, 9, 0, 9, 0, 1, 0, 1, 0, 2, 5 100, player
65, 0, 8, 0, 7, 0, 6, 0, 5, 1, 4 105, dealer
Manual Sample run:
87, 5, 8, 9, 7, 4, 6, 3, 9, 0, 2
P P P P D P D P D P
Total = 87
Players turn 5 Total 92
Dealers turn 4 Total 82
Players turn 8 Total 90
Dealers turn 3 total 93
Players turn 9 pass total 93
Dealers turn 0 Total 94
Players turn 7 Total 101
Total 101, Dealer is the winner as the card value exceeded when player was dealing the card
Solved
Show answers
More tips
- S Society and Politics Как правильно поддерживать температуру в квартире для здоровья...
- L Leisure and Entertainment How to Make a Crab Trap in Just a Few Minutes...
- H Health and Medicine How Much Does Abortion Cost? Expert Answers and Insights...
- S Sport How to Build Arm Muscles? Effective Exercises and Tips...
- H Health and Medicine When can it be said that a person has a normal pulse?...
- A Art and Culture When Will Eurovision 2011 Take Place?...
- S Style and Beauty How to Choose the Perfect Hair Straightener?...
- F Family and Home Why Having Pets at Home is Good for Your Health...
- H Health and Medicine How to perform artificial respiration?...
- H Health and Medicine 10 Tips for Avoiding Vitamin Deficiency...
Answers on questions: Computers and Technology
- C Computers and Technology What microprocessor was the first to be processable ?...
- B Business Give two examples of an administrative decision that would be based on performance management information. give two examples of developmental decisions based on this...
- M Mathematics Solve using the quadratic formula express answers in simplest radical form. x^2+4x+2=-2x+7...
- B Business Descriptive statistics statisticians understand non-numeric information, like colors can predict future stock returns with surprising accuracy refer mainly to patterns...
- M Mathematics The lengths of the base of a trapezoid is 12ft and 5ft the height is 96 in what is the area of the trapezoid...
- M Mathematics (b) what is the probability that the force is between 10 and 12 kips?...
- M Mathematics Given that bdfhj ~ qsuwy, what is wy...
- C Chemistry Can calcium or magnesium metal be disposed of down the drain...
- B Biology Bacterial sexually transmitted diseases, such as are becoming resistant to antibiotics....
- M Mathematics Two times the sum of a number and 8 is equal to 6...
Ответ:
numbers = input("Enter your numbers: (comma separated) ")
lst = numbers.split(",")
num_lst = ([])
for i in lst:
num_lst.append(int(i))
total = num_lst[0]
num_lst.pop(0)
player_hand = ([num_lst[0], num_lst[1], num_lst[2]])
num_lst.pop(0)
num_lst.pop(0)
num_lst.pop(0)
dealer_hand = ([])
for w in num_lst:
if num_lst.index(w) % 2 == 0:
player_hand.append(w)
else:
dealer_hand.append(w)
is_player = True
zero_count = 0
while True:
if is_player:
if player_hand[0] == 9:
total += 0
elif player_hand[0] == 4:
total -= 10
elif player_hand[0] == 0:
if total + 11 < 100 and zero_count == 0:
total += 1
else:
total += 1
else:
total += player_hand[0]
player_hand.pop(0)
if total > 99:
print("Total: {}. The dealer is the winner as the card value exceeded when the player was dealing the card.".format(total))
break
is_player = False
elif not is_player:
if dealer_hand[0] == 9:
total += 0
elif dealer_hand[0] == 4:
total -= 10
elif dealer_hand[0] == 0:
if total + 11 < 100 and zero_count == 0:
total += 1
else:
total += 1
else:
total += dealer_hand[0]
dealer_hand.pop(0)
if total > 99:
print("Total: {}. The player is the winner as the card value exceeded when the dealer was dealing the card.".format(total))
break
is_player = True
I hope this helps!
Ответ:
The file must be create first before using it. Because according to the question demanded, so far has it has not stated
Explanation:
Creating a file first