1. 程式人生 > >if else流程判斷

if else流程判斷

span think dbo blog use print 通過 log int

通過兩個例子學習if else判斷

1.if——else

# ifelse 判斷
_username = dmr
_password = 123
if username == _username and password == _password:
    print(welcome user {name} login .....format(name=username))
else:
    print(invalid username and password!)

2.if——elif——else

# elif
age_of_oldboy = 56
guess_age 
= int(input(guessage;)) if guess_age == age_of_oldboy: print(yes, you get it) elif guess_age <age_of_oldboy: print(think bigger) else: print(think smaller)

if else流程判斷