Python学习一
来源:互联网 发布:大学生分期购物软件 编辑:程序博客网 时间:2024/06/14 02:26
学习教材——麻省理工:计算机科学和 Python 编程导论
学堂在线课程网址:http://www.xuetangx.com/courses/course-v1:MITx+6_00_1x+sp/about
IDE:Enthought Canopy
- 编译型语言
- 优点:代码运行速度快,因为编译器会完成到低级语言的转换
- 缺点:找Bug难,因为要进入到编译后的指令中去
解释型语言(eg. Python)
- 优点:更容易找到Bug
- 缺点:慢一些,因为一次执行一条转换
数据类型:int、float、bool、str
运算符:“**”(平方)、*、/、+、-、各种不等号
提取字符串中的一部分(Extracting parts of strings)
- Indexing 索引
- ’abc’[1] returns ‘b’
- ‘abc’[-1] returns ‘c’ (0 -2 -1)
- Slicing 切片
- ’str’[start:end] starts at start, ends at end-1
- ‘abc’[1:3] returns ‘bc’
- Indexing 索引
raw_input:把获取的输入,当做字符串存储起来
- name = raw_input(‘Input your name: ‘)
- 如果需要一个int型,则需要进行类型转化
x = int( raw_input(‘Input a x: ‘) )
注释用#
条件判断示例:缩进一致代表处于同一循环
- ’elif’ means else if
x = int(raw_input('Enter an integer:'))if x%2 == 0: if x%3 == 0 print('')#此行输出一个换行 print('Divisible by 2 and 3') else: print('Divisible by 2 and not by 3')elif x%3 == 0: print('') print('Divisible by 3 and not by 2')else: print('Not divisible by 2 or 3')print('Done')
0 0
- Python学习一:Hello Python
- Python学习(一)
- Python学习笔记(一)
- Python学习笔记[一]
- Python学习(一)
- Python学习(一) 数值
- Python学习笔记一
- Python学习 (一)
- Python学习(一)
- Python学习积累《一》
- Python 学习积累《一》
- Python学习 一
- python学习(一):简介
- python学习(一)
- python学习(一)
- python学习笔记(一)
- python学习(一)
- Python学习总结(一)
- 检讨1
- Java static关键字
- Spring有关面试问题
- HDU 5805 NanoApe Loves Sequence
- Spark-Sql源码解析之六 PrepareForExecution: spark plan -> executed Plan
- Python学习一
- RTMP时间戳大于0xffffff,数据发送失败问题
- 论版本号的正确打开方式
- Java实现根据权重优先返回(速度较快)
- Java面对对象多态性
- 下载文件实现
- Leetcode 之Search a 2D Matrix
- 你好,Go
- 数据库索引的作用和优点缺点