码迷,mamicode.com
首页 > 编程语言 > 详细

Python中的分支条件结构

时间:2017-05-29 22:16:59      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:pre   word   style   python   条件   ice   else   put   print   

1. if 


1 #!/usr/bin/env python
2 #-*- coding:utf-8 -*-
3 user=input(‘Please input your username : ‘)
4 if user==admin:
5     print(Nice)

2. if ... else ...

1  #!/usr/bin/env python
2  #-*- coding:utf-8 -*-
3  user=input(Please input your username : )
4  pass=input(Please input your password: )
5  if user==admin and pass==123456:
6      print(Good)
7  else:
8      print(Bad)

 

3. if ... elif ... else ...

1  #!/usr/bin/env python
2  #-*- coding:utf-8 -*-
3 grade=(prompt=Please input your grade)
4 if grade>=85:
5     print(Great)
6 elif garde<85 and grade>=70:
7     print(Good)
8 else grade<70:
9     print(Bad)

 

Python中的分支条件结构

标签:pre   word   style   python   条件   ice   else   put   print   

原文地址:http://www.cnblogs.com/PythonInMyLife/p/6919074.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!