Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
bartleby

Videos

Question
Book Icon
Chapter 9, Problem 7PE
Program Plan Intro

Simulates craps game

Program Plan:

  • Import the header file.
  • Define the “main” method.
    • Call the “printIntro ()” method
    • Get the input from the user.
    • Call the “simNCraps ()” method and store it in a variable.
    • Call the “printSummary ()” method.
  • Define the “printIntro()” method.
    • Print the intro statements.
  • Define the “simNCraps()” method.
    • Set the values
    • Iterate “i” until it reaches “n” value
      • Check the condition
        • Increment the “winsA” value
      • Otherwise, increment the “losses” value.
      • Return the value.
  • Define the “simOneCraps ()” method
    • Call the “randrange ()” method
    • Check the “x” is equal to 2 or 3 or 12
      • Return false
          • Check the “x” is equal to 7 or 11
            • Return true
          • Otherwise,
            • Set the value
            • If “x” is not equal to “y” and 7
              • Call the “randrange ()” method
              • Check “y” is equal to 7
                • Return false
              • Check “y” is equal to “x”
                • Return true
  • Define the “printSummary ()” method
    • Display the results.
  • Call the main method.

Blurred answer
Students have asked these similar questions
Craps is a single player dice game, that proceeds as follows:1. the player rolls 2 six-sided dice once    if the total is 7 or 11, the player wins     if the total is 2, 3 or 12, the player loses    otherwise, the game continues, ... see 2 ... 2. the player the continues to roll the dice repeatedly, until ...    the total is the same as the original total (from 1), in which case the           player wins the total is 7, in which case the player loses Write a function craps using Python that simulates a single game of craps (may be many rolls) and returns 1 if the player wins and 0 otherwise.   Sample results examples: >> import random>>> random.seed(0)>>> craps()0 >>> random.seed(1)>>> craps()1 >>> random.seed(2)>>> craps()0 >>> [ (i,random.seed(i),craps()) for i in range(20)][(0, None, 0), (1, None, 1), (2, None, 0), (3, None, 1), (4, None, 0), (5, None,1), (6, None, 0), (7, None, 1), (8, None, 0), (9, None, 0), (10,…
Correct answer will be upvoted else downvoted. Computer science.    After painting the white cells of the board, you want to place the maximum number of dominoes on it, according to the following rules:   each domino covers two adjacent cells; each cell is covered by at most one domino; if a domino is placed horizontally (it covers two adjacent cells in one of the rows), it should cover only red cells; if a domino is placed vertically (it covers two adjacent cells in one of the columns), it should cover only blue cells. Let the value of the board be the maximum number of dominoes you can place. Calculate the sum of values of the board over all 2w possible ways to paint it. Since it can be huge, print it modulo 998244353.   Input The first line contains two integers n and m (1≤n,m≤3⋅105; nm≤3⋅105) — the number of rows and columns, respectively.   Then n lines follow, each line contains a string of m characters. The j-th character in the i-th string is * if the j-th cell in the i-th row…
In the Dice Roll game, the player begins with a score of 1000. The player is prompted for the numberof points to risk and a second prompt asks the player to choose either high or low. The player rollstwo dice and the outcome is compared to the player’s choice of high or low. If the dice total is between2 and 6 inclusive, then it is considered “low”. A total between 8 and 12 inclusive is “high”. A total of7 is neither high nor low, and the player loses the points at risk. If the player had called correctly, thepoints at risk are doubled and added to the total points. For a wrong call, the player loses the points atrisk. Create a DiceRollGame application that uses a DRPlayer object based on this specification. TheDRPlayer object should have two Die member variables that represent the dice. The Die class shoulduse a random number generator to determine the outcome in a roll() method. Application outputshould look similar to:
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
Program to find HCF & LCM of two numbers in C | #6 Coding Bytes; Author: FACE Prep;https://www.youtube.com/watch?v=mZA3cdalYN4;License: Standard YouTube License, CC-BY