Error in user YAML: (<unknown>): could not find expected ':' while scanning a simple key at line 3 column 1
---
- oeasy Python 0110
- 这是 oeasy 系统化 Python 教程,从基础一步步讲,扎实、完整、不跳步。愿意花时间学,就能真正学会。
本教程同步发布在:
个人网站: `https://oeasy.org`
蓝桥云课: `https://www.lanqiao.cn/courses/3584`
GitHub: `https://github.com/overmind1980/oeasy-python-tutorial`
Gitee: `https://gitee.com/overmind1980/oeasypython`
---- 配套视频
- 上次我们 了解了
- 列表的 乘法运算
- 乘法的本质 是 累加
- 规则 和加法类似
- 数据特别大时
- 会抛异常
- 列表的 乘法运算
- 列表 还有啥好玩的 吗?🤔
- 这题我会🙋
- 最大值 / 最小值
nl = list(range(5))
nl
maximum = max(nl)
maximum
minimum = min(nl)
minimum
- max 得到最大值
- min 得到最小值
- max算是啥呢?
help(max)
- max/min 都是 内置函数
- builtins
- 除了列表之外
- 好像还支持 多个参数?
max(1, 2)
min(1, 2)
- 可以从一堆值里面
- 找到最大值
- 有啥具体应用吗?
- 避免 极端值的影响
- 去掉一个最高分
- 去掉一个最低分
- 再求平均分
- 去奢去甚去泰
nl = list(range(10))
print(nl)
nl.remove(max(nl))
print(nl)
nl.remove(min(nl))
print(nl)
- 结果
- 把 0 和 9 都去掉了
avg(nl)
- 报错了
- 没有avg 这个函数
- 平均值函数
- 该怎么
求平均值呢??🤔
- 根据 平均值 定义
- 平均值 = 总和 ➗ 数量
avg = sum(nl) / len(nl)
avg
- 可以通过sum、len
- 间接 得到 avg
- 字符列表 也能有
最大值/最小值么?
cl = list("oeasy")
max(cl)
min(cl)
- 找 最大/最小
- 字符
怎么比大小 呢?
ord("a")
ord("y")
- 字符 有 自己的 序号
- ordinal
ord("y") > ord("a")
- 通过 序号 比大小
- 整体上啥情况
- 先退出 游乐场
- 回到 shell
sudo apt install ascii
ascii
- 字符的大小
- 由 ascii码的值 决定的
- 这次我们了解
- 最大值/最小值 函数
- max/min
- 可以直接给列表 排序 吗?
- 下次再说 👋
- 配套视频
- 本文来自 oeasy Python 系统教程。
- 想完整、扎实学 Python,
- 搜索 oeasy 即可。













