python学习笔记之基础数据和控制
注释:
单行注释 #
多行注释''' '''
注意:当注释中有汉字时需要在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
python学习笔记之基础数据和控制的更多相关文章
- Python学习笔记之基础篇(-)python介绍与安装
Python学习笔记之基础篇(-)初识python Python的理念:崇尚优美.清晰.简单,是一个优秀并广泛使用的语言. python的历史: 1989年,为了打发圣诞节假期,作者Guido开始写P ...
- Python学习笔记-Day1-Python基础
1.python诞生 关于Python的起源,吉多·范罗苏姆在1996年写到: 六 年前,在1989年12月,我在寻找一门“课余”编程项目来打发圣诞节前后的时间.我的办公室会关门,但我有一台家用电脑, ...
- Python学习笔记:基础
本文根据廖雪峰的博客,学习整理笔记.主要内容有:基本数据类型,容器数据类型,变量及其作用域,判断及循环语法,函数式编程,面向对象,模块等概念. 数据类型 在python中,能够直接处理的数据类型有以下 ...
- Python学习笔记day01--Python基础
1 python的应用 Python崇尚优美.清晰.简单,是一个优秀并广泛使用的语言. Python可以应用于众多领域,如:数据分析.组件集成.网络服务.图像处理.数值计算和科学计算等 ...
- 吴裕雄--天生自然python学习笔记:WEB数据抓取与分析
Web 数据抓取技术具有非常巨大的应用需求及价值, 用 Python 在网页上收集数据,不仅抓取数据的操作简单, 而且其数据分析功能也十分强大. 通过 Python 的时lib 组件中的 urlpar ...
- python学习笔记(基础四:模块初识、pyc和PyCodeObject是什么)
一.模块初识(一) 模块,也叫库.库有标准库第三方库. 注意事项:文件名不能和导入的模块名相同 1. sys模块 import sys print(sys.path) #打印环境变量 print(sy ...
- Python 学习笔记 编程基础汇总000
编程基础知识汇总000 1.计算机结构 2.编程语言分类 3.字符编码由来 计算机结构 计算机组成五大部件: 控制器.运算器.存储器.输入.输出 控制器(Controler):对程序规定的控制信息进行 ...
- Python 学习笔记(基础篇)
背景:今年开始搞 Data science ,学了 python 小半年,但一直没时间整理整理.这篇文章很基础,就是根据廖雪峰的 python 教程 整理了一下基础知识,再加上自己的一些拓展,方便自己 ...
- Python学习笔记之基础篇(二)python入门
一.pycharm 的下载与安装: 使用教程:https://www.cnblogs.com/jin-xin/articles/9811379.html 破解的方法:http://xianchang. ...
随机推荐
- Qt移动应用开发(三):使用精灵图片实现帧动画
Qt移动应用开发(三):使用精灵图片实现帧动画 上一篇博文讲到了Qt Quick对于动画的一般支持.动画的形式多样,配合不同的插值函数,能够差点儿实现全部想要的动画效果,而对于游戏的一些特殊的效果比方 ...
- Eclipse设置打印线
在调出Preferences之后,选中Text Editors.先选中Show print margin,在Print margin column框中填入180就可以,然后选择以下的Print mar ...
- winform禁用标题栏
protected override void WndProc(ref Message m) { if (m.Msg == 0x112) { switch ((int)m.WParam) { //禁止 ...
- 版本号控制-git(二)
上次文章给大家介绍了Git的一些基本知识(http://www.cnblogs.com/jerehedu/p/4582398.html).并介绍了使用git init初始化化版本号库.使用git ad ...
- spark-submit提交作业过程
1. 作业提交方法以及参数 我们先看一下用Spark Submit提交的方法吧,下面是从官方上面摘抄的内容. # Run application locally on 8 cores ./bin/sp ...
- JSTORM使用笔记
安装部署 zeromq 简单快速的传输层框架,安装如下: wget http://download.zeromq.org/zeromq-2.1.7.tar.gztar zxf zeromq-2.1.7 ...
- Linux文件实时同步,可实现一对多
说明:该功能服务端安装sersync2,客户端安装rsync,原理就是服务端主动推送设定目录下的所有更新的文件到各个客户端rsync接收. rsync大家都知道,是Linux自带的数据同步工具,而se ...
- assets raw 资源 AssetManager
assets raw 目录简介 assets核心特性:不会被编译成二进制,支持子目录(可以分类,这是相对raw目录最大的好处),通过文件名访问,调用getAssets通过AssetManager访问 ...
- 架构师书单 2nd Edition
了2007年的目标,列了下面待读或重读的书单. "其实中国程序员,现在最需要的是一张安静的书桌.",的确,中国架构师大多缺乏系统的基础知识,与其自欺欺人的宣扬"读书 ...
- Jenkins——应用篇——插件使用——Publish over SSH
本文是jenkins应用系统文章的一部分,大部分来自工作和学习中的实践,部分内容来自官方文档和网友的文章,引用的文章会在"參考资料"部分附上原始链接,如无意中侵犯您的权利.请联系Q ...