教程集 www.jiaochengji.com
教程集 >  Python编程  >  Python入门  >  正文 python中的分支有几种形式

python中的分支有几种形式

发布时间:2021-02-03   编辑:jiaochengji.com
教程集为您提供python中的分支有几种形式等资源,欢迎您收藏本站,我们将为您提供最新的python中的分支有几种形式资源

【相关学习推荐: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')

您可能感兴趣的文章:
python中的分支有几种形式
初识Python-Python的历史与优缺点
Python的特点(优点和缺点)
python编程软件有什么
简单介绍下python2.x与python3.x的区别
Python数值类型(整形、浮点型和复数)及其用法
python数据分析用什么软件
python图形界面开发用什么
学python一定要学django吗
学习Python却没看过这几本书,你就OUT了

[关闭]
~ ~