Python-based simple guess digital game, python-based guess digital

Source: Internet
Author: User

Python-based simple guess digital game, python-based guess digital

This example describes a simple guess digital game implemented by python. Share it with you for your reference. The details are as follows:

Given a number between 1 and 99, the user can guess the number. When the user guesses the error, the user will be prompted to guess whether the number is too large or too small, until the user guesses the number, the less you use the right number, the better your score.

Import randomn = random. randint (1, 99) guess = int (raw_input ("Enter an integer from 1 to 99:") while n! = "Guess": print if guess <n: print "guess is low" guess = int (raw_input ("Enter an integer from 1 to 99:") elif guess> n: print "guess is high" guess = int (raw_input ("Enter an integer from 1 to 99:") else: print "you guessed it! "Break print

I hope this article will help you with Python programming.

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.