[solved]-Need Help Python Dice Simulator Game Takes 4 Different Input Commands User User Enters Rol Q39014253
I need help with a python dice simulator game that takes 4different input commands from the user. When the user enters ‘RollX’ (X being the integer of rolls) the program is supposed to printthe Rolls of Dice X (Dice X being the number of dice rolled). Theprogram is buggy as it doesn’t print the correct number of dice.Finally, the ‘report’ command should yield the number of dice,rolls and the sum total. Can you help?
link to code: https://onlinegdb.com/rk7spOH-r
import random
import math
import shlex
total = 0
r = 0
def check_arguement(args):
if (len(args)>0) and (args[0].isdigit() == True) and(int(args[0]) > 0):
return int(args[0])
else:
return -1
### str_menu are the list of commands that the program excepts,basically how the app works
str_menu = ”’
Dice Simulator Console Application
1) How many Dice would you like? Command: Dice X, where X is aninteger 2-5, i.e., Dice 2
2) How many times do you want to Roll Command: Roll X, where X isan integer greater than zero; i.e., Roll 10
3) Would you like the Total Sum of your game play? Command:Report
4) Do you wish to Quit? Command: Quit
5) Do you need help? Command: Help
Enter command (Dice X, Roll X, Report, Quit) below:”’
print(str_menu)
###
while True:
try:
cmd, *args = shlex.split(input(‘> ‘))
if len(args) == 0:
args = []
except ValueError:
cmd = -1
console_arguement = check_arguement(args)
if cmd.lower() == ‘Dice’.lower():
if(console_arguement < 6 and console_arguement > 1):
print(‘You have selected Dice’, console_arguement)
else:
print(‘Error: you must input an integer between 2 – 5; i.e. Dice5’)
elif cmd.lower() == ‘Roll’.lower():
if(console_arguement > 0):
print(‘You have selected Roll’, console_arguement)
total = 0
for _ in range(console_arguement):
r = 0
for i in range(console_arguement):
roll = random.randint(1,6)
r += roll
print(roll, end=’ ‘)
print(‘, Sum =’, r)
total += r
else:
print(‘Error: you must input an integer greater than zero; i.e.Roll 5’)
elif cmd.lower() == ‘Report’.lower():
print(“Total dice used: “)
print(“Total of rolls =”, roll)
print(“Total sum of all rolls =”, total)
elif cmd.lower() == ‘Help’.lower():
print(‘Enter any of the follwoing commands (Dice X, Roll X, Report,Quit)’)
elif cmd.lower() == ‘Quit’.lower():
print(‘Thank you for using the Console Application’)
break
else:
print(‘Error: You entered an unknown command:’, cmd)

input Dice Simulator Console Application 1) How many Dice would you like? Command: Dice X, where x is an integer 2-5, i.e., Dice 2 2) How many times do you want to Roll Command: Roll x, where x is an integer greater than zero; i.e., Roll 10 3) Would you like the Total Sum of your game play? Command: Report 1) Do you wish to Quit? Command: Quit 5) Do you need help? Command: Help Enter command (Dice X, Roll x, Report, Quit) below: > dice 2 You have selected Dice 2 > roll 3 You have selected Roll 3 215, Sum = 8 4.15, Sum = 10 3 35, Sum = 11 > report Total dice used: Total of rolls = 5 Total sum of all rolls = 29 Show transcribed image text input Dice Simulator Console Application 1) How many Dice would you like? Command: Dice X, where x is an integer 2-5, i.e., Dice 2 2) How many times do you want to Roll Command: Roll x, where x is an integer greater than zero; i.e., Roll 10 3) Would you like the Total Sum of your game play? Command: Report 1) Do you wish to Quit? Command: Quit 5) Do you need help? Command: Help Enter command (Dice X, Roll x, Report, Quit) below: > dice 2 You have selected Dice 2 > roll 3 You have selected Roll 3 215, Sum = 8 4.15, Sum = 10 3 35, Sum = 11 > report Total dice used: Total of rolls = 5 Total sum of all rolls = 29
Expert Answer
Answer to I need help with a python dice simulator game that takes 4 different input commands from the user. When the user enters … . . .
OR

