if語句

user='liangml'
passwd='liangml'
username=input('username:')
password=input('password:')
#優化前
'''
if user ==  username:
print('usernameiscorrect...')
if passwd == password:
print('welcomelogin...')
else:
print('passwordifinvalid...')
else:
print('user name is not...')
'''
'''
#優化後
if user == username and passwd == password:
print('Welcomelogin')
else:
print('Invalid user name or password...')
'''

--------------------分界線----------------------
If語句猜年齡小遊戲
age=22
guess_num=int(input('inputyourguessnum:'))
if	guess_num==age:
print('Congratulations!yougotit.')
elif	guess_num>age:
print('Thinksmaller!')
else:
print('ThinkBig...')


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章