当前位置:网站首页>第2章-2 计算分段函数[1]
第2章-2 计算分段函数[1]
2022-07-28 07:15:00 【ZJUdebug3790】
本题目要求计算下列分段函数f(x)的值:

输入格式:
输入在一行中给出实数x。
输出格式:
在一行中按“f(x) = result”的格式输出,其中x与result都保留一位小数
正确代码:
s=float(input())
if s==0:
print("f(0.0) = 0.0")
else:
print("f(%.1f) = %.1f"%(s,1/s))之前报错,非0返回(最后一个测试点过不去)
s=int(input())
if s==0:
print("f(0.0) = 0.0")
else:
print("f(%.1f) = %.1f"%(s,1/s))发现是s的类型刚开始定义错了
边栏推荐
- Creation of status bar (29)
- ‘全局事件总线’&‘消息订阅与发布’
- pyflink连接iceberg 实践
- MCU IO port controls 12V voltage on and off, MOS and triode circuit
- Pyspark writes data to iceberg
- 思迈特软件完成C轮融资,让BI真正实现“普惠化”
- SQL function
- Understand the propagation process of EMI electromagnetic interference through five diagrams - the influence of square wave steepness on high-frequency components, the spectrum graph from time sequenc
- Sparksql and flinksql create and link table records
- PHPUnit在Window下如何配置
猜你喜欢

本人男,27岁技术经理,收入太高,心头慌得一比

Leetcode brushes questions. I recommend this video of the sister Xueba at station B

【OpenCV】生成透明的PNG图像

How to write a JMeter script common to the test team

中标捷报!南大通用GBase 8s中标南瑞集团2022年数据库框架项目

Half bridge buck circuit - record

单片机IO口控制12V电压通断,MOS和三极管电路

Starfish Os打造的元宇宙生态,跟MetaBell的合作只是开始

tkMapper的使用-超详细

UE4 engine customizes screenpass and MRT output
随机推荐
Usage of qcombobox
CarSim simulation quick start (XI) - Driver Model (1)
How does QT delete all controls in a layout?
Export SQL server query results to excel table
No super high-rise buildings | new regulations: what information does it reveal that no new buildings above 500 meters should be built?
PHP基础知识 - PHP 使用 MySQLI
Prescan quick start to proficient in lecture 17, speed curve editor
One key switch circuit
Understand the propagation process of EMI electromagnetic interference through five diagrams - the influence of square wave steepness on high-frequency components, the spectrum graph from time sequenc
百度智能云九州区县大脑,描绘城乡新蓝图!
【OpenCV】生成透明的PNG图像
Mysql-怎么添加用户和设置权限?
一篇文章搞懂数据仓库:元数据分类、元数据管理
[Qt5] a method of multi window parameter transmission (using custom signal slot) and case code download
解决:IndexError: index 13 is out of bounds for dimension 0 with size 13
Pyspark writes data to iceberg
When unity switches to another scene, he finds that the scene is dimmed
pyspark 写入数据到iceberg
Recruiting talents, gbase high-end talent recruitment in progress
pyflink连接iceberg 实践