python学习笔记之基础数据和控制
2014-06-06 14:50
681 查看
注释:
单行注释 #
多行注释''' '''
注意:当注释中有汉字时需要在python文件的第一行添加如下内容之一:#coding:gbk或#coding:utf-8或##-*- coding : gbk -*-
hello world 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基础,基本类型(整型,浮点数等)数据结构(List,dic(Map),Set,Tuple),控制语句(if,for,while,continue or break):来自学习资料
- Python学习笔记(二)——编程0基础数据分析进阶之路
- 学习笔记☞ python 基础(python3)【一】(python相关介绍,核心数据类型(数字),赋值语句,算数运算符优先级)
- Python玩转数据分析学习笔记-01基础
- 小甲鱼:Python学习笔记001_变量_分支_数据类型_运算符等基础
- 汇编语言 学习笔记(基础知识二----地址总线、数据总线、控制总线)
- 【学习笔记】Python基础-数据类型与变量
- Python3学习笔记【基础1--数据类型,运算符】
- Python学习笔记(一)--Python基础知识:变量、数据类型、模块与字符串
- Python学习笔记(0)——编程0基础数据分析进阶之路
- Day1 Python基础学习——概述、基本数据类型、流程控制
- Python3学习笔记(1)——基础和数据类型
- Java基础学习笔记(一)环境变量配置,数据类型,运算符,控制语句,循环语句
- 用Python玩转数据第一周学习笔记のPython基础
- 【零基础入门学习Python笔记005】闲聊之Python的数据类型
- python数据分析与挖掘学习笔记(1)-基础及准备
- Python学习笔记(一)——编程0基础数据分析进阶之路
- 学习笔记:Python基础 —— 数据类型和变量
- WCF学习笔记(四)数据契约、版本控制、错误
- Java学习笔记(一) Java基础以及数据类型介绍