手记

Python课堂笔记 条件控制语句

事例1
mood = False
if mood:
print('go to left')
else:
print('go to right')


事例2
ACCOUNT = 'qiyue'
PASSWORD = '123456'

print('please input account')
user_account = input()

print('please input password')
user_password = input()

if user_account == ACCOUNT and user_password == PASSWORD:
print('success')
else:
print('fail')


事例3
a = input()
print('a is ' + a)
a = int(a)
if a == 1:
print('apple')
elif a == 2:
print('orange')
elif a == 3:
print('banan')
else:
print('go shopping')


事例4
a = 1
b = 0
print(bool(a or b))

0人推荐
随时随地看视频
慕课网APP