当前位置:网站首页>实例049:lambda
实例049:lambda
2022-08-10 22:20:00 【懒笑翻】
题目:使用lambda来创建匿名函数。
程序分析:
传入 x,y ,返回内容是 x * (x >= y) + y * (y > x) 如果 x>=y成立则返回1,就返回x*1+y*0=x
代码:
Max = lambda x, y: x * (x >= y) + y * (y > x)
Min = lambda x, y: x * (x <= y) + y * (y < x)
a = int(input('1:'))
b = int(input('2:'))
print("max", Max(a, b))
print("min", Min(a, b))运行结果:

边栏推荐
- 音乐播放器(未完成版本)
- How does the Weiluntong touch screen display the current value of abnormal data while alarming?
- STL-stack
- 【640. Solving Equations】
- Black cat takes you to learn Makefile Part 11: When the header file a.h changes, how to recompile all the .c files that depend on the header file a.h
- 【640. 求解方程】
- 【开源教程5】疯壳·开源编队无人机-飞控固件烧写
- 艺术与科技的狂欢,阿那亚2022砂之盒沉浸艺术季
- 水果沙拉酱
- RecyclerView上下滑动时,不调用onBindViewHolder 导致列表的item不刷新
猜你喜欢

MySQL: MySQL Cluster - Principle and Configuration of Master-Slave Replication

PyQt5 窗口自适应大小

边缘与云计算:哪种解决方案更适合您的连接设备?

电力系统潮流计算(牛顿-拉夫逊法、高斯-赛德尔法、快速解耦法)(Matlab代码实现)

【640. 求解方程】

unusual understanding

shell programming without interaction

GMT,UTC,CST,DST,RTC,NTP,SNTP,NITZ: 嵌入式的时间

亲测有效|处理风控数据特征缺失的一种方法

艺术与科技的狂欢,阿那亚2022砂之盒沉浸艺术季
随机推荐
CFdiv2-Common Number-(奇偶数二分+规律)
OneNote 教程,如何在 OneNote 中整理笔记本?
字节跳动原来这么容易就能进去...
Addition of linked lists (2)
虚拟地址空间
virtual address space
JS中使用正则表达式g模式和非g模式的区别
高数_复习_第5章:多元函数微分学
常用代码扩展点设计方式
QT笔记——vs + qt 创建一个带界面的 dll 和 调用带界面的dll
QT笔记——QT工具uic,rcc,moc,qmake的使用和介绍
FPGA - Memory Resources of 7 Series FPGA Internal Structure -03- Built-in Error Correction Function
LeetCode每日两题02:反转字符串中的单词 (均1200道)
测试4年感觉和1、2年时没什么不同?这和应届生有什么区别?
fme csmapreprojector转换器使用高程异常模型进行高程基准转换
pytorch手撕CNN
H3C S5130 IRF做堆叠
QT笔记——用VS + qt 生成dll 和 调用生成的dll
阿里云架构师金云龙:基于云XR平台的视觉计算应用部署
OneNote tutorial, how to organize notebooks in OneNote?