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

Concept explainers

bartleby

Videos

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

Blackjack game

Program Plan:

  • Import the header file.
  • Define the main method.
    • Call the “printIntro ()” method.
    • Get the input from the user.
    • Call the “simNHands ()” method and store it in a variable.
    • Call the “printSummary ()” method.
  • Define the “printIntro ()” method.
    • Display the messages.
  • Define the “simNHands ()” method.
    • Set the values.
    • Iterate “i” until it reaches “n” value
      • Check the result of “simOneHand ()” is false
        • Increment the “busts” value
          • Return the “busts” value.
  • Definition of “simOneHand ()” method
    • Call the simOneCard ()” methods and store it in a different variables.
    • Calculate “hand” value
    • Check the “hand” value is less than 17
      • Check  the result of “hasAce (x)” is true
        • Check the “hand “value is less than or equal to 10
          • Set the “x” value as 11.
          • Calculate the “hand” value
        • Otherwise, set the “x” value as 1.
      • Check the result of “hasAce (y)” is true
        • Check the “hand “value is less than or equal to 10
          • Set the “y” value as 11.
          • Calculate the “hand” value
        • Otherwise, set the “y” value as 1.
      • Call the method and store it in a variable
      • Calculate the “hand” value
      • Check “hand” value is greater than 21
        • Return false
      • Otherwise, return true
  • Define the “simOneCard ()” method
    • Call the method with the arguments
    • Check “x” is equal to 11 or 12 or 13
      • Set the “x” as 10
      • Return “x”
            • Otherwise, return “x” value
  • Define the “hasAce ()” method
    • Check “x” is equal to 1
      • Return true
            • Otherwise, return false.
  • Define the “printSummary ()” method
    • Display the output.
  • 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,…
One variation on the game of nim is described in Luger. The game begins with a single pile of stones. The move by a player consists of dividing a pile into two piles that contain an unequal number of stones. For example, if one pile contains six stones, it could be subdivided into piles of five and one, or four and two, but not three and three. The first player who cannot make a move loses the game. (5.1) Draw the complete game tree for this version of Nim if the start state consists of six stones. (5.2) Perform a minimax evaluation for this game. Let 1 denote a win and 0 a loss.
Use java language
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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Control Structure in Data Structure - Data Structures - Computer Science Class 12; Author: Ekeeda;https://www.youtube.com/watch?v=9FTw2pXLhv4;License: Standard YouTube License, CC-BY