if

  • A+
所属分类:python
1.用户登录
import getpass
user = 'test'
passwd = '123'

username = input('what is your name?:')
password = getpass.getpass('Please your password:')

if  user == username and passwd == password:
    print('Hello ' + username)
else:
    print('你输入的账户密码错误')
2.猜数字
mynum = 27

guess_num = int(input('input your guess num:'))
if guess_num == mynum:
    print('恭喜你猜对了!')
elif guess_num > mynum:
    print('你猜的数字太大了!')
else:
    print('你猜的数字太小了!')


avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: