python note #1
To record my process of studying python and to practice my English meanwhile, I'd like to start write my blog about python with English. = ^ =
Part 1_Hello World!
print (' Hello World! ')
This code can show the best reason why I'd like to study python. Because it's so simple, clean and elegant. With python, setting language environment is not needed anymore. Just use 'print', everything is done!
Part 2_History & Development of Character Encoding
- ASCII: best for English, which only takes up 1 bytes of your storage.
 
- Chinese: take up 3 bytes
 

- Unicode: ISO released unicode to unite diffrent standards of character encoding between countries. But it took up 2 bytes to store English. To improve it, utf-8 was released. With utf-8, only 1 bytes was needed while storing English.
 
Part 3_Variety
Rules
- Combination of character, number and underscores.
 - Don't use key words as the name of the variety.
 - Name the variety with its meaning.
 - With CAPITAL LETTERS naming a variety, it means that the variety is constant.
 
How to use?
name = 'It's a good day!'
# name a variety
name2 = name
# give a value to a new variety
print (' What' the weather like today?', name, name2)
# use varieties
variety
'''
function1:多行注释
function2:多行打印
'''
message='''
Do you like this blog?
If yes, that's great!
If no, leave you suggestions, and I'll improve it ASAP!
'''
print(message)
usage of '''
Part 4_Interaction
'Input' is used to get information from users. And 'print' is used to output the information.
 name = input (' Please input your name:')
 age = input("Please input your age:")
 #加入int,代表integer,整型,字符串的格式化
 job = input("Please input your job:")
 salary = input("Please input your salary:")
 info = '''
 -------------------info of {NAME} --------------------------
 NAME: {NAME}
 AGE: {AGE}
 JOB: {JOB}
 SALARY: {SALARY}
 ----------------------------------------------------------------
 ''' .format(NAME=name, AGE=age, JOB=job, SALARY=salary)
 print (info)
interaction
Part 5_Loop ( if, elif, for, while )
Combination of If, While and Elif
Qiao is one of my roomates. To show my respect for her, I took advantage of her birth year information to write a code for you to guess. Ofcourse, please do not read the code directly. Cuz in this way, you'll get the answer directly...
birthyear_of_qiao = 1997
count = 0
while count<3:
guess = int(input("猜猜乔的出生年份:"))
if guess == birthyear_of_qiao:
print("干的漂亮,你猜对了!")
break
elif guess > birthyear_of_qiao:
print("她哪有那么年轻?!!!")
else:
print("她还没那么老,好嘛。。。")
count +=1
if count == 3:
if_continue = input('是否要继续呢?继续的话请输入Y,退出的话请输入N:')
if if_continue == 'Y':
count = 0
else:
print ('猜不中还早早退出,太塑料兄弟情了!')
break
else:
print('游戏失败。。。')
loop_if_while_elif
For
# continue是跳出本次循环,进入到下一次循环
# break是结束全部循环
for i in range(0,10,2):
if i <5:
print("loop",i)
else:
continue
print('嘻嘻') # 循环套循环,执行一次大循环,下面执行六次小循环
for i in range(10):
print ('-------------------',i)
for j in range(10):
print(j)
if j>5:
break
python note #1的更多相关文章
- python note
		
=和C一样,为赋值.==为判断,等于.但是,在python中是不支持行内赋值的,所以,这样避免了在判断的时候少写一个出错. dictionary 的key唯一,值可以为很多类型. list的exten ...
 - python note 4
		
1.使用命令行打开文件 t=open('D:\py\123.txt','r') t.read() 在python和很多程序语言中""转义符号,要想输出\要么多加一个\写成\ 要么在 ...
 - python note 17 random、time、sys、os模块
		
1.random模块(取随机数模块) # 取随机小数 : 数学计算 import random print(random.random())# 取0-1之间的小数 print(random.unifo ...
 - python note 16 re模块的使用
		
1.re模块(#regex) # 查找 # findall : 匹配所有 每一项都是列表中的一个元素 import re ret = re.findall('\d+','dawdawd154wadwa ...
 - python note 15 正则表达式
		
# 正则表达式 只和字符串打交道 # 正则表达式的规则# 规则 字符串 从字符串中找到符合规则的内容 # 字符组 : [] 写在中括号中的内容,都出现在下面的某一个字符的位置上都是符合规则的 # [0 ...
 - python note 12 生成器、推导式
		
1.生成器函数 # 函数中如果有yield 这个函数就是生成器函数. 生成器函数() 获取的是生成器. 这个时候不执行函数# yield: 相当于return 可以返回数据. 但是yield不会彻底中 ...
 - python note 10 函数变量
		
1.命名空间 #内置命名空间 —— python解释器 # 就是python解释器一启动就可以使用的名字存储在内置命名空间中 # 内置的名字在启动解释器的时候被加载进内存里#全局命名空间 —— 我们写 ...
 - python note  01 计算机基础与变量
		
1.计算机基础. 2.python历史. 宏观上:python2 与 python3 区别: python2 源码不标准,混乱,重复代码太多, python3 统一 标准,去除重复代码. 3.pyth ...
 - python note of decorator
		
def decorate_log(decorate_arg,*args,**kwargs): # 存放装饰器参数 def decorate_wrapper(func,*args,**kwargs): ...
 
随机推荐
- HD-ACM算法专攻系列(5)——N!
			
题目描述: 源码: #include"iostream" using namespace std; int main() { int n, digit, carry, tmp; i ...
 - Android 对话框黑色边框的解决
			
代码解决 : Dialog dialog = new Dialog(this); Window win = dialog.getWindow(); win.setBackgroundDrawableR ...
 - 乌班图 之 apt命令 及 VMware共享文件夹
			
apt是Advanced Packaging Tool ,是Ubuntu下的一个安装包管理工具 大部分软件的安装.更新.卸载 都是利用apt命令来实现 直接在终端输入apt即可查阅命令的帮助信息 常用 ...
 - 从 MVC 到微服务,技术演变的必经之路
			
架构模式演进 CGI 模式 图 1 CGI 出现于 1993 年,图 1 是 CGI 模式比较简单的结构图. MVC 模式 开源电商软件等都是采用 MVC 模式,MVC 模式是做软件开发必学和必经历的 ...
 - ZBrush雕刻生物小技巧
			
本教程主要学习如何使用ZBrush®3D图形绘制软件的工具和笔刷雕刻酷酷的生物造型,我们今天来看看在游戏.媒体和电视领域有着十几年丰富经验的3D角色艺术家Francis-Xavier Martins是 ...
 - 洛谷P3254 圆桌问题 网络流_二分图
			
Code: #include<cstdio> #include<algorithm> #include<vector> #include<queue> ...
 - [arc082e]ConvexScore
			
题意: 给出直角坐标系中的$N$个点$(X_i,Y_i)$,定义由其中部分点构成的点集为“凸点集”当且仅当这些点恰好能构成一个凸多边形(内部没有其他点). 如图,点集$\{A,C,E\}$和$\{B, ...
 - [CTSC2016]单调上升路径
			
题目:UOJ#201. 题目大意:给定n个点(n是偶数)的完全图,现在要你给每条边确定一个权值(互不相等),使得最长的单调上升路径最短.现在要你输出边的权值. 一条路径被称为单调上升的,如果沿着它走时 ...
 - df -h 挂死
			
df -h 卡死的情况,那是因为无法统计挂载的目录的大小 一般是因为还挂载了一些外部的目录,如nfs的目录 可以用mount | column -t 命令查看哪些目录 然后umount这些目录, 一般 ...
 - bzoj1051: [HAOI2006]受欢迎的牛(强联通)
			
1051: [HAOI2006]受欢迎的牛 题目:传送门 题解: 今天又做一道水题... 强联通啊很明显 水个模板之后统计一下每个强联通分量中点的个数,再统计一下出度... 不难发现:缩点之后当且仅当 ...