注释:

单行注释 #

多行注释'''    '''

注意:当注释中有汉字时需要在python文件的第一行添加如下内容之一:#coding:gbk#coding:utf-8##-*- coding : gbk -*-

hello world python:

#coding:utf-8
'''
Created on 2014-6-6 @author: yzl
''' print '----------基础类型的操作----------'
i = 10
print i
i = i+10
print i
print i*2 if i==20:
print 'i==',i str = 'string '
print str*2 bool = True or False
print bool s='this is test string \
hello world python'
print s l='''thi is test string
test to print hello world python'''
print l print '---------控制语句---------' # wait user input
num = int(raw_input('Enter an integer :'))
if num<10:
print 'this number is < 10'
elif num>=10 and num<=100:
print 'this number is bettween 10 and 100'
else:
print 'yeah! the num is:',num
for j in range(1,num):
if j<5:
continue
if j>=10:
break
print 'for run :',j step = 0
while bool:
if num<100:
step = step +1
print 'case 1,step is:',step
if step > 10:
break
elif num>=100:
bool = False
print 'case 2 to stop while'
# 当bool为false时执行
else:
print 'go to else case'

运行结果:

----------基础类型的操作----------
10
20
40
i== 20
string string
True
this is test string hello world python
thi is test string
test to print hello world python
---------控制语句---------
Enter an integer :200
yeah! the num is: 200
for run : 5
for run : 6
for run : 7
for run : 8
for run : 9
case 2 to stop while
go to else case Enter an integer :30
this number is bettween 10 and 100
for run : 5
for run : 6
for run : 7
for run : 8
for run : 9
case 1,step is: 1
case 1,step is: 2
case 1,step is: 3
case 1,step is: 4
case 1,step is: 5
case 1,step is: 6
case 1,step is: 7
case 1,step is: 8
case 1,step is: 9
case 1,step is: 10
case 1,step is: 11

最新文章

  1. 推荐一些python Beautiful Soup学习网址
  2. python使用SMTP发送邮件
  3. ios 7.1.2 拍照声音
  4. JS-010-覆盖率测试工具 JSCoverage 初识
  5. Codeforce Round #217 Div2
  6. git项目实战常用workflow和命令
  7. Mysql配置文件my.cnf解析
  8. 使用CATransition实现页面的“从左向右” “从右向左”的动画
  9. TypeScript 中的 SOLID 原则
  10. Linux系列教程(十)——Linux文本编辑器vim
  11. 杨老师课堂_Java核心技术下之控制台模拟微博用户注册案例
  12. Python3 tkinter基础 Scale orient 横竖 resolution单步步长 length 长度 tickinterval 指示刻度
  13. cmake中添加-fPIC编译选项方法
  14. Docker端口映射及创建镜像演示(二)--技术流ken
  15. Jenkins在windows服务器上依赖的maven仓库目录
  16. 前端学习 之 Bootstrap (一)
  17. Javaweb学习笔记——(五)——————DOM&XML目录
  18. 主成分分析(PCA)原理详解
  19. 写一个限制上传文件大小和格式的jQuery插件
  20. 微信小程序之可滚动视图 scroll-view 的使用注意

热门文章

  1. 【Linux】在虚拟机上安装CentOS7
  2. 新手学习selenium路线图(老司机亲手绘制)-学前篇
  3. fedora 系统 能够以 root 用户进行登录
  4. git跟踪远程分支,查看本地分支追踪和远程分支的关系
  5. 异常:javax.el.PropertyNotFoundException: Property &#39;id&#39; not found on ..........
  6. JDBC进阶之PreparedStatement执行SQL语句(MySQL)
  7. 启动Memcached报错:/usr/local/memcached/bin/memcached: error while loading shared libraries: libevent-2.1.so.6: cannot open shared object file: No such file or directory
  8. uva 10160 Servicing Stations(DFS+剪枝)
  9. Android完全退出程序、线程
  10. Android -- PullToRefresh应用