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

最新文章

  1. Java Collection开发技巧
  2. C# Winform防止一个程序重复运行
  3. http tcp udp ip 间的关系
  4. SqlServer服务器和数据库角色
  5. IBM B16光纤交换机ZOON划分方法
  6. [Effective JavaScript 笔记]第43条:使用Object的直接实例构造轻量级的字典
  7. HLG2062(make,heap问题)
  8. android wheelview 滚轮控件
  9. ***常见复杂SQL语句(含统计类SQL)
  10. [置顶] MapReduce 编程之 倒排索引
  11. Reactor构架模式--转载
  12. 编译Boost 详细步骤
  13. 使用Fiddler捕获Java程序中的HTTP请求
  14. ODP.NET 之访问 Oracle 数据库
  15. eclipse debug 多线程
  16. JUnit4 与 JMock 之双剑合璧
  17. MyBatis之TypeHandler
  18. jenkins+ant+jmeter自动化环境搭建(一)
  19. [翻译 EF Core in Action 1.6]你的第一个EF Core应用程序
  20. 分支界定( BRANCH-AND-BOUND)

热门文章

  1. Shiro授权认证原理和流程
  2. STL数组和com数组相互转换的做法
  3. 编译Speex生成so库文件(android-speex)
  4. CF 287(div 2) B Amr and Pins
  5. windows2008搭建ftp服务器
  6. Dapper优秀资料
  7. P2421 [NOI2002]荒岛野人 扩展欧几里得 枚举
  8. 紫书 例题 11-5 UVa 10048 (Floyd求最大权值最小的路径)
  9. 【BZOJ 1208】[HNOI2004]宠物收养所
  10. 洛谷 P2027 bf