Python programming Quick start of the 10th Chapter Practical Project Reference Answer (10.8)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.