通过两个例子学习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‘)
时间: 2024-11-03 23:03:38