Python优点:学习成本低、免费、开源、适用广
一、计算机的组成
1、软件系统和硬件系统组成
2、重点:CPU(中央处理器):处理指令和运算数据+内存:存储数据(cpu要处理的数据)
3、学习路径:python入门 - 流程控制(条件语句,循环) - 数据序列 - 函数 - 文件操作 - 面向对象(类和对象,继承) - 模块、包、异常 - 项目实战
二、python入门
1、解释器:运行文件
1)种类:Cpython(官方、常用)、Ipython、其他解释器
2、官方下载网址
验证安装成功:cmd进入命令符,输入python 回车
退出:exit()
3、pycharm:是一种python IDE(集成开发环境)
①新建项目:注意项目保存路径及解释器(existing interpreter)
②新建文件并书写代码:根目录右键→[new]→[Python File]→输入文件名
③书写代码:print(" ")
④界面设置
File→settings(ctrl+alt+s)→Appearance & Behavior→Appearance/ Editor


⑤修改解释器
File | Settings | Project: PycharmProject | Project Interpreter| add | system Interpreter | ...


⑥项目管理

4、注释:单行:#(ctrl+/);多行""" """,''' '''
5、变量:
1)作用:就是一个存储数据的时候当前数据所在的存储地址的名字
2)变量定义:在 Python 中,每个变量 在使用前都必须赋值,变量 赋值以后 该变量 才会被创建
变量名=值
6、bug → debug调试(打断点)
7、数据类型

8、格式化符号
age = 18
name = 'TOM'
weight = 75.5
student_id = 1
# 我的名字是TOM
print('我的名字是%s' % name)
# 我的学号是0001
print('我的学号是%4d' % student_id)
# 我的体重是75.50公斤
print('我的体重是%.2f公斤' % weight)
# 我的名字是TOM,今年18岁了
print('我的名字是%s,今年%d岁了' % (name, age))
# 我的名字是TOM,明年19岁了
print('我的名字是%s,明年%d岁了' % (name, age + 1))
# 我的名字是TOM,明年19岁了
print(f'我的名字是{name}, 明年{age + 1}岁了')
常用格式化符号
练习:

注意:f格式化:f ' {表达式} ' →print(f'我的名字是{ name },今年{ age }岁')
9、转义字符
\n换行 :print("hello\nword")
\t指标符:print('\tabcd') 制表符是:一个tab键(4个空格)距离
10、输入input
1、语法:input( "提示信息" )
①遇到input,等待用户输入
②接受的input存变量
③input会把接受的输入的信息当做字符串处理
2、转换数据类型

11、运算符

Python基础导图

网友评论