A game of throwing dice is played between two players. Each player throws a dice unless his scores add up to 20.The player getting score 20 in minimum number of throws is declared winner.
Answers
Python program for an automatic rolling dice game.
Note: Due to some issues, we have placed ^ in place of the letter 'n' in the ra^dint. Please replace all the ^ with the letter 'n' in this program. Thank you!
Program:
import random
p1=0
p2=0
while(p1<20 and p2<20):
a=random.ra^dint(1,6)
print("Player A rolling dice... The value is",a)
p1=p1+a
b=random.ra^dint(1,6)
print("Player B rolling dice... The value is",b)
p2=p2+b
if p1>=20 and p2>=20:
print("Match draw!")
break
elif p1>=20:
print("The winner is Player A")
break
elif p2>=20:
print("The winner is Player B")
break
Output:
Player A rolling dice... The value is 6
Player B rolling dice... The value is 2
Player A rolling dice... The value is 6
Player B rolling dice... The value is 2
Player A rolling dice... The value is 3
Player B rolling dice... The value is 2
Player A rolling dice... The value is 3
Player B rolling dice... The value is 4
Player A rolling dice... The value is 2
Player B rolling dice... The value is 1
The winner is Player A
Learn more:
1. Raju has a square-shaped puzzle made up of small square pieces containing numbers on them. He wants to rearrange the puzzle by changing the elements of a row into a column element and column element into a row element. Help Raju to solve this puzzle.
https://brainly.in/question/16956126
2. Printing all the palindromes formed by a palindrome word.
brainly.in/question/19151384