摘要: # 让一个数字和他相邻的数字比较, # 如果前一个数字大于后一个数字,交换两个数据的位置 nums = [3, 2, 1, 6, 5, 4] j = 0 while j < len(nums) - 1: flag = True # 假设每一趟都没换行 i = 0 while i < len(nums 阅读全文
posted @ 2020-07-13 11:32 kaiyaoweixiao 阅读(118) 评论(0) 推荐(0) 编辑
摘要: #九九乘法表 #i = 0 #控制内循环 j = 0# 控制外循环 while j < 9: j += 1 i = 0 while i < j: i += 1 print(f'{i}*{j}={i * j}',end ='\t ',sep='') print() ''' ''' for i in r 阅读全文
posted @ 2020-07-13 11:30 kaiyaoweixiao 阅读(101) 评论(0) 推荐(0) 编辑
摘要: max_num = int(input('请输入一个数:')) while True: num = int(input('请在输入一个数:')) if num > max_num: max_num = num else: if num == 0: break print(max_num) 阅读全文
posted @ 2020-07-13 11:26 kaiyaoweixiao 阅读(124) 评论(0) 推荐(0) 编辑
摘要: li = [i for i in range(1,101)] start_index = 0 end_index = len(li)-1 num = int(input('您要找的数是:') while start_index <= end_index : mid_index = (start_in 阅读全文
posted @ 2020-07-13 11:21 kaiyaoweixiao 阅读(132) 评论(0) 推荐(0) 编辑
摘要: s1 = 'python,java,php,go,c,python,java,php,go,c,python,java,php,go,c,' #统计每个单词出现的次数, l1 = s1.split(',') print(l1) dic = {} #创建新字典 for i in l1 : if i n 阅读全文
posted @ 2020-07-13 11:13 kaiyaoweixiao 阅读(161) 评论(0) 推荐(0) 编辑