I learned python for about a week. I wrote a game that guessed numbers !, Python guess number

Source: Internet
Author: User

I learned python for about a week. I wrote a game that guessed numbers !, Python guess number

Print ("-------------------------------------------------------")
Print ("-------------------------------------------------------")
Print ("-------------- this is a game that guesses numbers from each other -----------------")
Print (''' is up to you to guess. This is a number between 1 and!
Now the computer has determined a number. What do you guess! ''')
Luckynumber = 67
Ln = int (input ("Enter the number you guessed :"))
While not ln = luckynumber:
If ln <luckynumber:
Print ("the number you entered is smaller than my number! ")
Else:
Print ("the number you entered is larger than my number! ")
Ln = int (input ("Please input again :"))
Print ("You guessed it! Is ", ln)
Print ("---------------------------------------------------------")
Print ("---------------------------------------------------------")
Print ("now it's the computer's time to guess. Please set a number between 0 and in your mind ")
Print ("if I guess the number is larger than your number, enter B. If it is smaller than your number, enter s. If it is equal, enter e! ")
Print ("are you sure you want to know, computer started to guess! Press any key to start ")
Ln = range (1, 101)
While not len (ln) = 1:
Luckynumber = ln [len (ln) // 2]
Answer = input ("is" + str (luckynumber) +? Please answer :")
If answer = "B ":
Lista = len (ln) // 2
Ln = ln [: lista]
Elif answer = "s ":
Listb = len (ln) // 2
Ln = ln [listb:]
Elif answer = "e ":
Break
Else:
Print ("Enter three answers: B, s, and e! ")


# Nb = 0
# Sodium = 100
# Ln = nb + (na-nb) // 2
# Answer = ln
# While not answer = "e ":
# Ln = nb + (na-nb) // 2
# If answer = "B ":
# Na = ln
# Elif answer = "s ":
# Nb = ln
# Else:
# Print ("Enter B, s, and e answers! ")
# Answer = input ("is" + str (ln) +? Please answer :")

Print ("I guess it is", luckynumber)
#    s=""
#    for i in range(101):
#        s=s+str(i)+" "
#Print (s)

# There are two solutions: Numbers and lists. The comment contains the number scheme.

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.