![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python基础
Python基础
Layson4869
吧唧吧唧
展开
-
Python实现快速排序
def partiton(li,left,right): temp = li[left] while left < right: while left < right and li[right] >= temp: right -= 1 li[left] = li[right] while left < right and li[left] <= temp: left原创 2021-05-30 23:59:54 · 113 阅读 · 0 评论 -
【Python】字典的setdefault()方法
这是一道统计目标句子中单词组合出现次数的题目,输出的是一个字典:wordstring = 'it was the best of times it was the worst of times \it was the age of wisdom it was the age of foolishness'# write your code belowdef get_pair_freq1(wordstring): wordlist = wordstring.split(" ") #分解成.原创 2020-11-21 00:36:07 · 573 阅读 · 0 评论 -
Python之记两道列表生成式的题目
题目一乍一看貌似挺简单,不就上下两列表一一对应,建一个字典把名字放到对应数字组的列表里students = ['Tom', 'Kitty', 'Jessie', 'Chester', 'Curie', 'Darwing', 'Nancy', 'Sue', 'Peter', 'Andrew', 'Karren', 'Charles', 'Nikhil', 'Justin', 'Astha']assignment = [2, 3, 3, 1, 3, 2, 3, 1, 1, 1原创 2020-11-10 02:38:53 · 225 阅读 · 0 评论