09 2020 档案

摘要:0. 请使用lambda表达式将下边函数转变为匿名函数? def fun_A(x, y=3): return x * y fun_A = lambda x,y=3 : x*y; #lamba不需要对函数命名,分号隔开参数以及函数表达式 a. Python写一些执行脚本时,使用匿名函数就可以省下定义函 阅读全文
posted @ 2020-09-29 11:46 celine227 阅读(188) 评论(0) 推荐(0)
摘要:题目1:密码安全性检查代码# 低级密码要求:1. 密码由单纯的数字或字母组成2. 密码长度小于等于8位# 中级密码要求:1. 密码必须由数字、字母或特殊字符(仅限:~!@#$%^&*()_=-/,.?<>;:[]{}|\)任意两种组合2. 密码长度不能低于8位#高级密码要求: 1. 密码必须由数字、 阅读全文
posted @ 2020-09-22 16:03 celine227 阅读(510) 评论(0) 推荐(0)
摘要:题目1. 三色球问题 有红、黄、蓝三种颜色的求,其中红球 3 个,黄球 3 个,绿球 6 个。先将这 12 个球 混合放在一个盒子中,从中任意摸出 8 个球,编程计算摸出球的各种颜色搭配。 #print('red\tyellow\tblue')for red in range(0, 4): for 阅读全文
posted @ 2020-09-22 15:54 celine227 阅读(183) 评论(0) 推荐(0)
摘要:import random;times = 3#random.randint表示模块中的随机数secret = random.randint(1,10)temp = input("不妨猜一下小甲鱼心里想的数字:")guess = int(temp)while (guess != secret) an 阅读全文
posted @ 2020-09-22 15:39 celine227 阅读(232) 评论(0) 推荐(0)
摘要:题目1. 编写一个函数,判断传入的字符串参数是否为“回文联”(回文联即用 回文形式写成的对联,既可顺读,也可倒读。例如:上海自来水来自海上) def hwl(strA): if strA == strA[::-1]:#倒序字符串的方法[::-1] return True else: return F 阅读全文
posted @ 2020-09-22 15:38 celine227 阅读(216) 评论(0) 推荐(0)
摘要:题目1. 编写一个函数 findstr(),该函数统计一个长度为 2 的子字符串在另一个字符串中出现的次数。例如:假定输入的字符串为“You cannot improve your past, but you can improve your future. Once time is wasted, 阅读全文
posted @ 2020-09-22 15:35 celine227 阅读(229) 评论(0) 推荐(0)
摘要:score = int(input("请输入一个分数:"))if 100 >= score >= 90: print("A")elif score >= 80: print("B")elif score >= 60: print("C")elif score >= 0: print("D")else 阅读全文
posted @ 2020-09-22 15:24 celine227 阅读(247) 评论(0) 推荐(0)
摘要:temp = input("不妨猜一下小甲鱼心里想的是哪个数字:")num = int(temp)#input输出永远是字符串while type(num) != type(4): print("抱歉,输入不合法,",end='')#end=''取消换行print默认换行 temp = input( 阅读全文
posted @ 2020-09-22 15:21 celine227 阅读(216) 评论(0) 推荐(0)
摘要:import random#random.randint表示模块中的随机数secret = random.randint(1,10)temp = input("不妨猜一下小甲鱼心里想的数字:")guess = int(temp)while guess != secret: temp = input( 阅读全文
posted @ 2020-09-22 15:19 celine227 阅读(222) 评论(0) 推荐(0)