![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
每周一个python小项目
作为初学者,每周写一个python小程序,可能很简单,但想要记录下自己学习成长的每一步。
Jianzhi.Z
这个作者很懒,什么都没留下…
展开
-
2020.11.03 大写变小写并统计每个词出现的频率
2020.11.03 大写变小写并统计每个词出现的频率要求:给定一段英文:I have a dream that my four little children will one day live in a nation where they will not be judged by the color of their skin but by the content of their character. I have a dream today. I have a dream that one d原创 2020-11-08 00:01:17 · 489 阅读 · 0 评论 -
2020.11.02 倒转列表
2020.11.02 倒转列表要求:已知info=[1,2,3,4,5],用两种方法,将列表变成info=[5,4,3,2,1]代码:# 2、已知info=[1,2,3,4,5],用两种方法,将列表变成info=[5,4,3,2,1]# 方法一thislist = [1, 2, 3, 4, 5]thislist.reverse()print(thislist)# 方法二thislist = [1, 2, 3, 4, 5]newlist = [] # 创建新的列表for x in原创 2020-11-07 23:41:50 · 168 阅读 · 0 评论 -
2020.11.01 统计输入字符串中每种符号的次数
2020.11.01 统计输入字符串中每种符号的次数要求:输入一行字符串,包括字母、数字、符号和空格,请编写程序统计每种符号出现的次数。代码:# 练习: 1、输入一行字符串,包括字母、数字、符号和空格,请编写程序统计每种符号出现的次数。symbol = input("请输入符号:")thisdict = dict() # 创建一个新的字典for x in symbol: if x in thisdict: # 如果字符在字典中存在,则对应的键的值加1 thisdi原创 2020-11-07 23:39:13 · 249 阅读 · 0 评论 -
2020.10.31 打印前十个斐波那契数列
2020.10.31 打印前十个斐波那契数列要求:使用循环,编写一个Python程序,打印出前10个Fibonacci数代码:# 1.使用循环,编写一个Python程序,打印出前10个Fibonacci数a, b = 1, 1print("Fibonacci数: ")for i in range(5): print(a, b, end=' ') a = a+b b = a+b结果:Fibonacci数:1 1 2 3 5 8 13 21 34 55...原创 2020-11-07 23:34:17 · 522 阅读 · 0 评论 -
2020.10.26 将1-50中的奇偶数存放在不同的列表
2020.10.26 将1-50中的奇偶数存放在不同的列表要求:编写一个Python程序,它迭代整数从1到50(使用for循环)。对于偶数的整数,将其附加到列表代码:# 编写一个Python程序,它迭代整数从1到50(使用for循环)。对于偶数的整数,将其附加到列表even_num = []odd_num = []for num in range(1,51): if num % 2 == 0: even_num.append(num) else:原创 2020-11-07 23:30:19 · 1539 阅读 · 0 评论 -
2020.10.25 删除文本的标点并转换成列表
2020.10.25 删除文本的标点并转换成列表要求:从文本中删除标点符号并将最终产品转换为列表代码:# 从文本中删除标点符号并将最终产品转换为列表:# On a dark desert highway, cool wind in my hair Warm smell of colitas, rising up through the air Up ahead in the distance, I saw a shimmering light My head grew heavy and my s原创 2020-11-07 23:21:40 · 182 阅读 · 0 评论