day2

2018-07-17  本文已影响0人  木偶演员

01 HelloWorld 入门必备

快捷方式学习:
   control + / ----单行注释
   control + s---保存
   control + b----编译
   control + c---复制
   control + z---撤销
   control + y ---反撤销
1.print函数是python的内置函数,作用是控制台打印print括号里面的内容.
2.print括号的里的双引号是字符串的标志

02 python基础语法

一.注释
二.标识符
三.关键字

1.系统保留的 有特殊功能的或有特殊意义的单词,这些单词不能用来变量等
2.关键字有:

                    'False', 'None', 'True', 'and' , 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield'
四.行与缩进
五.关于行的规范

六.字面量

10,100,234 ---->整数
12.5,14.5 ----->小数
"12"---->字符串

整数:int
浮点数:float
布尔:bool
复数:complex

数字(整数,浮点型,布尔,复数) 字符串(str) 列表(list),字典(dict),元组(tuple) none(空)

03 变量

python变量:
怎么声明变量

age = 18 #声明并赋值
print(age) #使用
age = 18
student = age
print(student)
student = 20
print(age)
print(student)
student_age = 20

04 运算符

运算符分类

1 .数学运算符(+ - * / % ** // )
2.比较运算符(<> == >= <= !=)
**3.逻辑运算符 **

and 和 需要一个或者多个条件同时满足
or 或 多个条件满足一个条件
not 非 需要不满足某个条件

4.赋值运算符
          >=
          +=
          -+
          *=
          /=
          %=
          **=
          //=

作用:将赋值符号右边的表达式的值赋给左边的变量
表达式:有结果的语句
注意 赋值符号的左边必须是变量

5.优先级

优先级从低到高: 赋值 逻辑 比较 算术
resulut =10+20>15 and 7*8<30+60
结论:算术运算中 先幂运算再加减取余取整再加减
括号 拥有最大优先权

05 进制转换

上一篇 下一篇

猜你喜欢

热点阅读