当前位置:网站首页>实例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))
运行结果:
边栏推荐
- Extended Chinese Remainder Theorem
- Black cats take you learn Makefile article 13: a Makefile collection compile problem
- Merge k sorted linked lists
- shell脚本
- 带着昇腾去旅行:一日看尽金陵城里的AI胜景
- Qualcomm Platform Development Series Explanation (Application) Introduction to QCMAP Application Framework
- port forwarding
- STL-deque
- 留言有奖|OpenBMB x 清华大学NLP:大模型公开课更新完结!
- 这款可视化工具神器,更直观易用!太爱了
猜你喜欢
阿里云新增三大高性能计算解决方案,助力生命科学行业快速发展
配电网络扩展规划:考虑使用概率性能源生产和消费概况的决策(Matlab代码实现)
Shell 编程--Sed
OneNote tutorial, how to organize notebooks in OneNote?
3598. Binary tree traversal (Huazhong University of Science and Technology exam questions)
音乐播放器(未完成版本)
《DevOps围炉夜话》- Pilot - CNCF开源DevOps项目DevStream简介 - feat. PMC成员胡涛
Pro-test is effective | A method to deal with missing features of risk control data
Service - DNS forward and reverse domain name resolution service
2022年8月10日:使用 ASP.NET Core 为初学者构建 Web 应用程序--使用 ASP.NET Core 创建 Web UI(没看懂需要再看一遍)
随机推荐
How many threads does LabVIEW allocate?
Service - DNS forward and reverse domain name resolution service
SDP
shell programming without interaction
virtual address space
爬虫request.get()出现错误
HanLP词性表
What is Jmeter? What are the principle steps used by Jmeter?
自学软件测试不知道该如何学起,【软件测试技能图谱|自学测试路线图】
Introduction to the use of counter instructions in Rockwell AB PLC RSLogix5000
68:第六章:开发文章服务:1:内容梳理;article表介绍;创建【article】文章服务;
win系统下pytorch深度学习环境安装
学会开会|成为有连接感组织的重要技能
An article to teach you a quick start and basic explanation of Pytest, be sure to read
2022年8月10日:使用 ASP.NET Core 为初学者构建 Web 应用程序--使用 ASP.NET Core 创建 Web UI(没看懂需要再看一遍)
How to translate financial annual report, why choose a professional translation company?
云服务器基于 SSH 协议实现免密登录
今日睡眠质量记录75分
美味的佳肴
美味石井饭菜