【相关学习推荐:python教程】
python中的分支有三种形式,分别是:
1、if
#!/usr/bin/env python
#-*- coding:utf-8 -*-
user=input('Please input your username : ')
if user=='admin':5 print('Nice')
2、 if ... else ...
#!/usr/bin/env python
#-*- coding:utf-8 -*-
user=input('Please input your username : ')
pass=input('Please input your password: ')
if user=='admin' and pass=='123456':
print('Good')
else:
print('Bad')
3、if ... elif ... else ...
#!/usr/bin/env python
#-*- coding:utf-8 -*-
grade=(prompt='Please input your grade')
if grade>=85:
print('Great')
elif garde<85 and grade>=70:
print('Good')
else grade<70:
print('Bad')