Menu

[solved]-Write Steps Python New Game Initialization New Use Step Wise Refinement Separate Details C Q39011535

How to write these steps in Python:

  • NEW *** Game Initialization: *** NEW
    • Use step-wise refinement to separate out all the details forthe code into the function def generateCode(): thatreturns the code
      • Randomly generate the 4-digit code between 0999 and9999
      • Mathematically – use the logic from digitsOfNumber to separatethe code into the 4 separate variables of code0,code1, code2, code3
      • If any of the digits of the code 0-3 are duplicates anew code must be generated randomly until all digits areunique. Print each code that is generated until a correctcode is generated.
  • NEW *** Input: *** NEW
    • Use step-wise refinement to separate out all the details forthe user input into the function def getInput(): thatreturns guesswith all validation checks in the function
      • Input: guess
      • String indexing – use the logic from lettersInWord to separatethe guess into the 4 separate variables ofguess0, guess1, guess2,guess3
      • Complete validation check on the guess making sure a4-digit number was entered, with each digit being unique. If notvalid, reprompt the user to enter a new guess and print anerror message.
  • NEW *** Game Play Single Turn: *** NEW
    • Convert all code 0-3 variables and guess 0-3variables into the same data type
    • Create function: checkBulls(code, guess): to take thecode and guess and return the turn results forbullCount
    • Create function: checkCows(code, guess): to take thecode and guess and return the turn results forcowCount
    • Using the value returned from the functions, play the game ofbulls and cows to completion.

Expert Answer


Answer to How to write these steps in Python: NEW *** Game Initialization: *** NEW Use step-wise refinement to separate out all th… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *