Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create the game Bulls and Cowse this version will have a few modifications though! Your game will have the following functions A a function that
Create the game Bulls and Cowse this version will have a few modifications though! Your game will have the following functions A a function that writes to a file. It will take in as arguments the file name and text. The function should append any text provided to it plus a new line into the provided file when called. 8. a function that generates the secret code. It should have no arguments but it should return the generated code as a string. b . Duplicate digits are allowed and any number from 0000 to 9999 should be generated (I suggest using randint from the random module to help you with this.) C a function that asks the player to type input. This function has no arguments but should output a string with instructions to the player before every guess and provide information about what kind of input is expected It should return what the user typed as input D. a function that checks to see if the input is the correct length. The argument is the input text. The function returns true or false depending on if the input is the correct length E a function that determines the number of bulls, it will take in the player's guess and the secret code as arguments and return the number of bulls in the guess F a function that lets the user play cows and bulls 1. Call function to generate the secret code. Use function A to write the secret code to a file. Use this same hile for the entire assignment 2. Use Functions C&D to get input and verify it is the right length. Keep prompting for input until you have a valid guess or the user want to quit by typing Qora 3. When a proper guess has been made, write the player's guess to the hile using Function with the number guess it is something like Guess ax: xxxx where the Xs are replaced by the appropriate values) 4. Use function to set the number of bulls 5. If the player puessed the secret code, the game is over. Print a single congratulatory statement that includes the number of guesses it took to win in your congratulatory statement. Also write the same statement to the file using function A 6. If the player did not guess the secret code, report the number of bulls to the player by outputting it in a single print statement with appropriate text 7. Keep looping until the game is over either by a correct guess or quitting BONUS Does not need to be a separate her let the player play as many comes as they want. After each game of Bulls and cows ask if they want to play acain and only buy again if they type Yory. BONUS (5 SUBMIT BONUS AS SEPARATE FILE clearly marked as bonus. You will not get any bonus points of the normal assignment does not work ita digit is correct, but in the wrong location, that is a cow keep track of cows as well and report them in Step 5. This bonus task is not easy which is why it is worth 5 points. Do not search for code on the internet and use it. You will get a ero on the entire assignment in my solution I created two more functions and modified my bull function to have different output to make this work Make sure you comment your additions well Decent attempts at reasoning out this bonus will get some points
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started