![](https://img-blog.csdnimg.cn/2019092715111047.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
py作业
0.0
shiki99
无经验,刚开始学习的新人
展开
-
python作业5——消消乐
相邻的组合两两相消去,最后是否能消完 str = "{[()]{}[[]]}[()]" def search(a, lst): # 寻找元素是否在列表中,并返回index for i in range(len(lst)): if lst[i] == a: return i else: return False def check(str): # 判断是否可消完 open_bracket = ['(', '[', '{']原创 2020-07-31 15:45:42 · 402 阅读 · 0 评论 -
python作业4
用面积法求pi的值: pi = 4 * ratio( area_of_round / area_of_square # determine pi import random point_num_round = 0 point_num_square = 0 # count the point number of each figure for i in range(1001 * 1001): # 相当于创建了一个1001 * 1001的坐标系 row = random.randint(0, 1001原创 2020-07-28 01:15:46 · 85 阅读 · 0 评论 -
python作业3
我的方法:用字典创建一个旋转函数 # my method def func_rotate( s ): # the funtion to rotate a valid digit switcher ={ # dic like c: switch,case 0:0, 1:1, 2:5, 5:2, 6:9, 8:8, 9:6, } return switcher.get(s, "in.原创 2020-07-28 01:00:12 · 83 阅读 · 0 评论 -
python作业2
1.Using while loop, calculate there are how many consecutive zeros from the right side of a positive integer number. e.g. for 123000, answer is 3 for 123456, answer is 0 for 100230, answer is 1 # Using while loop, calculate there are how many # consecuti原创 2020-07-28 00:55:14 · 862 阅读 · 0 评论 -
python作业1
1.打印前十个质数 Print first 10 primer numbers # print first 10 primer numbers j=0 # 对素数数的计数 for num in range(2, 100): for i in range(2, num): if num % i == 0: break else: # 如果没执行break,就会到执行else if j < 10: print(n原创 2020-07-28 00:38:49 · 228 阅读 · 0 评论