python学习日记-实战(2)
来源:互联网 发布:qq网络加速器 编辑:程序博客网 时间:2024/04/29 06:24
- 问题1
- 问题2
- 问题3
问题1
定义一个函数,接收3个参数,返回一元二次方程:
的两个解。
def solve_quadratic(a, b, c): if b * b - 4 * a * c < 0: raise ValueError a, b = (-b + sqrt(b * b - 4 * a * c)) / (2 * a), (-b - sqrt(b * b - 4 * a * c)) / (2 * a) return a, b
问题2
输入
L = ["Hello", "World", 18, "Apple", None]
输出为各个英语单词的小写
[s.lower() for s in L1 if isinstance(s, str)]
问题3
杨辉三角的生成器
def triangles(): a = [1] while True: yield a a = [a[i-1] + a[i] for i in range(1, int(len(a)))] a.insert(0, 1) a.append(1)
阅读全文
0 0
- python学习日记-实战(2)
- python学习日记(2)
- python 学习日记(一)
- python学习日记(一)
- python学习日记(1)
- python学习日记(3)
- python学习日记(一)
- python学习日记(4)
- python学习日记(5)
- python学习日记(6)
- python学习日记(7)
- python学习日记(8)
- python学习日记(9)
- python学习日记(一)
- python学习日记(二)
- python学习日记(三)
- python学习日记(四)
- python学习日记2--基础语法篇
- RMAN概述
- 距离近了,心却远了
- M100的飞行模式
- javaweb基础知识整合和servlet简介
- 使用递归方式求最大公约数和最小公倍数
- python学习日记-实战(2)
- 解决Visual Studio Community 2017工具栏中没有Report Viewer的问题
- 个人Javaweb项目介绍
- include搜索路径
- LeetCode Clone Graph
- 各版本KMS秘钥KMS的GVLK秘钥
- GMIS 2017 大会陈雨强演讲:机器学习模型,宽与深的大战
- Difference between JOIN and JOIN FETCH in JPA
- PHP之上传文件