jack0he的个人博客分享 http://blog.sciencenet.cn/u/jack0he

博文

Python-Note-1-If-else-statements

已有 2106 次阅读 2017-4-10 17:47 |个人分类:Python 笔记|系统分类:科研笔记

1, If statements

if condition:

   xxxx


Example:

name='alibaba'

if name=='alibaba':

   print('My name is alibaba')


2, else statements

Example:

name='alibaba'

if name=='alibaba':

   print('My name is alibaba')

else:

   print('Who are you?')


3, elif statements (= else if)

age=20

if age<15:

   print('You are young')

elif age<30:

   print('You are junior')

elif age<50:

   print('Your are senior')

else:

   print('You are old')


Keep in mind: not forget the ":" after the definition of a condition




https://blog.sciencenet.cn/blog-850613-1047978.html

上一篇:matlab-plotyy
下一篇:Python-Note-2-While-loop-statements
收藏 IP: 80.101.95.*| 热度|

1 张海权

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-24 23:44

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部