1 #Debug shows that the guess input (heads, tails) and toss content (0,1) are inconsistent and need to be modified and toss Compared. 2 Importrandom,logging3Logging.basicconfig (level=logging. DEBUG, format='% (asctime) s-% (levelname) s-% (message) s')4Logging.debug ('Start of Program')5Guess ="'6n="' #Add a function n7 whileGuess not inch('Heads','Tails'):8 Print('Guess the coin toss! Enter heads or Tails:')9Guess =input ()TenLogging.debug ('inputwords: (%s%%)'% (GUESS))#Debug Guess content one ifGuess = = ('Heads'): an = 1 - elifGuess = = ('Tails'): -n =0 theLogging.debug ('inputwords: (%s%%)'% (N))#Debug N Content -Toss = Random.randint (0, 1)#0 is tails, 1 is heads -Logging.debug ('toss: (%s%%)'% (TOSS))#Debug Toss Content - ifToss = =N: + Print('you got it!') - Else: + Print('nope! Guess again!') aGuesss =input () at ifToss = =N: - Print('you got it!') - Else: - Print('Nope. you is really bad at the this Game.')
Python programming Quick start of the 10th Chapter Practical Project Reference Answer (10.8)