当前位置:网站首页>第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的类型刚开始定义错了
边栏推荐
- CAT1 4g+ Ethernet development board 232 data is sent to the server through 4G module TCP
- Use of namespaces
- Half bridge buck circuit - record
- 49-OpenCv深入分析轮廓
- How does QT delete all controls in a layout?
- Recommend a fully open source, feature rich, beautiful interface mall system
- JS cartoon English alphabet typing game source code
- Allure use
- SQL注入 ----前置基础
- Shell编程规范与变量
猜你喜欢

See how Google uses pre training weights in target detection tasks | CVPR 2022

How to build the protection system of class protection technology of 2022 series of ISO compliance (Part I)

Can‘t connect to server on ‘IP‘ (60)

When will brain like intelligence, which is popular in academia, land? Let's listen to what the industry masters say - qubits, colliders, x-knowledge Technology

The cooperation between starfish OS and metabell is just the beginning

SQL注入 ----前置基础

客户至上 | 国产BI领跑者,思迈特软件完成C轮融资

PMP practice once a day | don't get lost in the exam -7.13

阿里巴巴内部面试资料

解决EMC、EMI传导干扰的八大方法
随机推荐
2022 Niuke multi school first problem solving Report
Blog Building 9: add search function to Hugo
[Qt5] small software with 5 people randomly selected from the bid evaluation expert base
PostgreSQL is the world's most advanced open source relational database
博客搭建七:hugo
opengauss同步状态疑问
c语言中函数的介绍(血书20000字!!!!)
Mysql-怎么添加用户和设置权限?
Usage of qmap
JS cartoon English alphabet typing game source code
Introduction to self drive tour of snow mountains in the West in January 2018
Maximum product of leetcode/ word length
百度智能云九州区县大脑,描绘城乡新蓝图!
Characteristics of EMC EMI beads
CAT1 4g+ Ethernet development board 232 data is sent to the server through 4G module TCP
Window 2 - > toolbar (28-1)
The fourth phase (2021-2022) research on the implementation of cloud native technology in traditional industries - central state-owned enterprises was officially released
How to set it to pop up the right-click menu
Use of namespaces
招贤纳士,GBASE高端人才招募进行中