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))

【转自慕课】https://www.imooc.com

Python

Python入门到实践-循环

2022-3-3 18:51:49

Python

李伟的Python学习手记3

2022-3-3 18:52:19

搜索