当前位置:网站首页>实例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))
运行结果:
边栏推荐
- 美味的石井饭
- ArcGIS中的坐标系统和投影变换
- “数据引擎”开启前装规模量产新赛道,「智协慧同」崭露头角
- 配电网络扩展规划:考虑使用概率性能源生产和消费概况的决策(Matlab代码实现)
- 【640. Solving Equations】
- Spark基础【RDD转换算子】
- Distribution Network Expansion Planning: Consider Decisions Using Probabilistic Energy Production and Consumption Profiles (Matlab Code Implementation)
- 【开源教程5】疯壳·开源编队无人机-飞控固件烧写
- Why general company will say "go back messages such as" after the end of the interview, rather than just tell the interviewer the result?
- FPGA - Memory Resources of 7 Series FPGA Internal Structure -03- Built-in Error Correction Function
猜你喜欢
随机推荐
Shell 编程--Sed
分享一个后台管理系统可拖拽式组件的设计思路
过滤器
文件IO-缓冲区
【640. 求解方程】
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
RecyclerView滑动监听
Extended Chinese Remainder Theorem
Conditional Statements of Shell Programming (2)
Addition of linked lists (2)
An article to teach you a quick start and basic explanation of Pytest, be sure to read
SDP
H3C S5130 IRF做堆叠
CIKM2022 | 基于双向Transformers对比学习的序列推荐
Power system power flow calculation (Newton-Raphson method, Gauss-Seidel method, fast decoupling method) (Matlab code implementation)
Detailed installation steps and environment configuration of geemap
电力系统潮流计算(牛顿-拉夫逊法、高斯-赛德尔法、快速解耦法)(Matlab代码实现)
August 10, 2022: Building Web Applications for Beginners with ASP.NET Core -- Creating Web UIs with ASP.NET Core
Glide监听Activity生命周期源码分析
Black cat takes you to learn Makefile Part 12: Summary of common Makefile problems