基础DAY1-注释 语言规范 算数运算符

syntax 语法

indentation  缩进 

unexpected indent  出乎意料的缩进

declare 公布

interactive 交互式

python shell

交换式

退出解释器 exit() or 快捷键ctrl+d

IPython interactive 交互式

自动补全 自动缩进  支持bash shell命令

退出 exit or 快捷键ctrl+d

PyCharm 

文件导航区 编辑区  控制台输出

注释

单行注释(行注释)

# 注释加一个空格,格式规范,否则有虚线 ,橙色灯泡 reformat file,自动改格式

如果在代码右侧,空两格

多行注释(块注释)

一对连续的三个引号 or 单引号

 1 # 这是注释
 2 print("hello")  # 这是注释
 3 # 这是第二个注释
 4 '''
 5 这是个多行注释
 6 。。。
 7 。。。
 8 print("hello")
 9 print("hello world")
10 '''
注释
 1 # 变量的类型
 2 """
 3 姓名:晓明
 4 年龄:18岁
 5 性别:是男生
 6 身高:1.75米
 7 体重:75.0公斤
 8 """
 9 # str 字符串
10 name = "晓明"  # type: str
11 # int 整数
12 age = 18
13 # bool 表示是一个布尔类型,False  True
14 gender = True
15 # float 浮点数,表示是一个带小数
16 height = 1.75
17 weight = 75
18 print(name)
19 print(age)
变量的类型-个人信息

语言规范

https://zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_language_rules/

算数运算符

+ 加

- 减

* 乘

/ 除

// 取整除

% 取余数

** 幂 次方 乘方 最高优先级

运算符可以用于字符串

In [13]: "..." * 3
Out[13]: '.........'

优先级

先乘除后加减

同级运算符从左往右运算

可以用()调整计算的优先级

原文地址:https://www.cnblogs.com/joycezhou/p/11312359.html