Python学习[00]
来源:互联网 发布:诺兰蝙蝠侠三部曲知乎 编辑:程序博客网 时间:2024/06/07 06:33
[00]Learn Python——Python Syntax
1.Variables
Creating web apps, games, and search engines all involve storing and working with different types of data. They do so using variables. A variable stores a piece of data, and gives it a specific name.
spam = 5
2.Booleans
A boolean is like a light switch. It can only have two values. Just like a light switch can only be on or off, a boolean can only be True or False.
a = Trueb = False
3.Whitespace for indentation
In Python, whitespace is used to structure code. Whitespace is important, so you have to be careful with how you use it.Usually we use 4 blank space or 2 blank space**or**1 Tab。
def spam(): eggs = 12 return eggsprint spam()
4.Single Line Comments/Multi-line Comments
The # sign is for comments. A comment is a line of text that Python won’t try to run as code. It’s just for humans to read.
For multi-line comments, you can include the whole block in a set of triple quotation marks:
"""Sipping from your cup 'til it runneth over,Holy Grail."""
5.Math
addition = 72 + 23subtraction = 108 - 204multiplication = 108 * 0.5division = 108 / 9exponentiation = 2 ** 3modulo = 3 % 2
6.Bringing It All Together
- Variables, which store values for later use
- Data types, such as numbers and booleans
- Whitespace, which separates statements
- Comments, which make your code easier to read
- Arithmetic operations, including +, -, , /, *, and %
- Python学习[00]
- python机器学习日志.00
- 【Python学习】Python 关键字
- Python学习----Python基础
- 【python】:python学习笔记
- Python:Python学习总结
- Python学习-Python数据类型
- Python学习
- 学习python
- python学习
- 学习Python
- python学习
- python学习
- python学习
- python 学习
- 学习python
- Python学习
- Python 学习
- java一个简单的自定义异常工具类
- poj 2688 Cleaning Robot
- [剑指offer]面试题7:用两个栈实现队列
- 树莓派安装中文字库与中文输入法
- File类使用详解
- Python学习[00]
- Anaconda+pyqt+Eric6
- [ZJOI2007]时态同步(洛谷1131)
- BaSh重定向操作用法
- java 基础Hello World 小笔记
- 后台返回的map转成json的形式
- C语言中const关键字的用法
- 求二叉树的最小深度。
- UVA