Description: A enter a numeric value, enter the value is hidden can not see, let B guess how much, the value is too small or too large will prompt, and will be in the last guess the number of guesses a few times.
Script content:
#!/usr/bin/env python
#FileName: while1.py
Import Getpass #调用模块
a = Int (Getpass.getpass (' Enter A number A: ')) #模块赋值
running = True
i = 0
While running:
b = Int (raw_input (' Enter A number B: '))
If a = = B:
print ' \033[32mgood,your Password is Ture!\033[0m '
running = False
i = i+1
Elif a < b:
print ' Bad,pleas Try again! is Too greate! '
i = i+1
Else
print ' Bad,pleas Try again! is Too little! '
i = i+1
Else
print ' \033[36mwhat a clever boy!\033[0m '
if i = = 1:
print ' \033[36myou used%s chance to give the answer '% i
Else
print ' \033[36myou used%s chances to give the answer '% i
This article is from the "L.P.F" blog, make sure to keep this source http://liupengfang1015.blog.51cto.com/6627801/1742776
"Python note three" Python Script combat---Digital password games