码迷,mamicode.com
首页 > 其他好文 > 详细

If——else初探

时间:2017-09-29 19:32:38      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:user   class   ons   习题   number   else   word   blog   import   

#密文密码

1 import getpass
2 password = getpass.getpass("passwd:")

#If——else

 1 user = gdr
 2 pass_wd = 123456
 3 
 4 username = input("username:")
 5 password = input("password:")
 6 
 7 if user == username and pass_wd == password:
 8     print("%s login!!" % username)
 9 else:
10     print("Wrong username or password!!")

#猜数字练习题

guess_number = int(22)
get_number = int(input(Please enter the number you guessed>>>))

if guess_number == get_number:
    print("Congratulations, you guessed it")
elif guess_number > get_number:
    print("The number you guessed is too small")
else:
    print("The number you guessed is too big")

 

If——else初探

标签:user   class   ons   习题   number   else   word   blog   import   

原文地址:http://www.cnblogs.com/jesse-gong/p/7612178.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!