Question: I am working on python functions and a double dice roll game. I just wanted to know what's wrong with my python code and what
I am working on python functions and a double dice roll game. I just wanted to know what's wrong with my python code and what I can improve on.
Sample of question: Write a program to simulate the game of casino craps. Below is a simple set of rules that you MUST follow: The player must roll two six-sided dice and add the total of both dice. The player will win on the first roll if they get a total of 7 or 11 The player will lose on the first roll if they get a total of 2, 3, or 12 If they get any other result (4, 5, 6, 8, 9, 10), they must roll again until they either match their first roll (a win) or get a result of 7 (a loss) For your program, you must include the following: You must repeat a craps game 10,000 times and keep track of the total of wins and losses Use at least two functions in your program The only printout is two lines, the final sum of wins and losses
And here is what I have in my code so far. Excuse the comment out sections I was just typing.

Spyder File Edit Search Source Run Debug Consoles Projects Tools View Help IC ll C: E = >> C:\Users\jalav Object C:\Users\jalav\,spyder-py3\temp.py o temp.py* Source Console import random as rd Usage def diceroll(number, type=6): result = @ for i in range(number): result += rd.randrange(1, type+1) return result Here you can get help of any object by pressing Ctrl+L in front of it, either on the Editor or the Console. Help can also be shown automatically after writing a left parenthesis next to an object. You can activate this behavior in Preferences > Help New to Spyder? Read our tutorial for num in range (10000): print(diceRoll(2), end="") result = diceroll(2) #thePoint = @ #intwin = @ #intlose = @ #if result == 7 or 11: #output += " You Win" #intwin += 1 #elif result == 2 or 3 or 12: #output += " You Lose" #intlose += 1 Variable explorer Help Plots Files O Console 1/A 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 28 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 48 41 42 Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] Type "copyright", "credits" or "license" for more information. #else: #thePoint = result #output += " Roll Again" #print(output) IPython 7.19.0 -- An enhanced Interactive Python. In [1]: #check = True #while check: #if thePoint == result: #output + " You win" #intwin += 1 #elif thePoint == 7: #output + " You lose" #intlose + 1 #else: #output += " Roll again" #print(output) IPython console History custom (Python 3.7.9) Line 38, Col 13 LSP Python: ready ASCII CRLF RW Mem 83 Type here to search 1 O FI N W ( 5:25 PM 2/7/2021
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
