Improve Digital Games

Source: Internet
Author: User

Greater than
= greater than or equal to
< less than
<= less than or equal to
= = equals
! = Not equal to

Judgment statement
If condition:
Operation performed with Condition True (true)
Else
Action performed on condition False (false)

While condition:
Operation performed with Condition True (true)

temp = input ("Please enter a number:")
guess = Int (temp)
While guess! = 8:
temp = Inpur ("Guess wrong, please reenter a number:")
guess = = Int (temp)
if guess = = 8:
Print ("You are the one in my Heart")
Print ("Unfortunately no reward")
Else
If guess > 8:
Print ("Big, Big")
Else
Print ("Little Xiao Xiao")
Print ("Game Over")

Number of Cycles
temp = input ("Please enter a number:")
guess = Int (temp)
Err_time = 0
While Err_time < 3:
temp = input ("Wrong guessing, please reenter a number:")
guess = Int (temp)
if guess = = 8:
Print ("Are you the one in my heart?") ")
Print ("Guessing is useless")
Break
Else
If guess > 8:
Print ("Big, Big")
Else
Print ("Little Xiao Xiao")
Err_time+=1
Else
Print ("Try Too many times")
Print ("Game Over")

Random module
Return results after generating random numbers
Import Random
num = Random.randint (1,10)
guess = int (num)
Err_time = 0
While Err_time < 3:
num = input ("Please enter a number:")
guess = int (num)
if guess = = 8:
Print ("Are you the one in my heart?") ")
Print ("Guessing is useless")
Break
Else
If guess > 8:
Print ("Big, Big")
Else
Print ("Little Xiao Xiao")
Err_time+=1
Else
Print ("Try Too many times")
Print ("Game Over")

Improve Digital Games

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.