7-31 jmu-分段函数l (20 分)
本题目要求计算以下分段函数的值(x为从键盘输入的一个任意实数):

如果输入非数字,则输出“Input Error!”
输入格式:
在一行中输入一个实数x。
输出格式:
在一行中按”y=result”的格式输出,其中result保留两位小数。
输入样例:
-2
输出样例:
在这里给出相应的输出。例如:
y=3.00
def demo1(x):
if x > 1:
y = 2 * x + 1
elif x > -2:
y = 3
else:
y = -2 * x - 1
print("y={:.2f}".format(y)) try:
x = eval(input())
demo1(x)
except Exception as result:
print("Input Error!")
7-31 jmu-分段函数l (20 分)的更多相关文章
- PTA 邻接表存储图的广度优先遍历(20 分)
6-2 邻接表存储图的广度优先遍历(20 分) 试实现邻接表存储图的广度优先遍历. 函数接口定义: void BFS ( LGraph Graph, Vertex S, void (*Visit)(V ...
- 第三次实验计算分段函数 第四次计算分段函数和循环NEW 第五次分支+循环加强版 实验报告
一.实验题目,设计思路,实现方法 第四次分支+循环 加强版 (2-2计算个人所得税,2-7 装睡,2-8计算天数) 设计思路:2-2 用if-else的语句,与计算分段函数的题类似的做法:2-7 运用 ...
- 1011 World Cup Betting (20 分)
1011 World Cup Betting (20 分) With the 2010 FIFA World Cup running, football fans the world over wer ...
- A1035 Password (20)(20 分)
A1035 Password (20)(20 分) To prepare for PAT, the judge sometimes has to generate random passwords f ...
- pat 1011 World Cup Betting(20 分)
1011 World Cup Betting(20 分) With the 2010 FIFA World Cup running, football fans the world over were ...
- PAT甲级——1152.Google Recruitment (20分)
1152 Google Recruitment (20分) In July 2004, Google posted on a giant billboard along Highway 101 in ...
- PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642
PAT (Advanced Level) Practice 1011 World Cup Betting (20 分) 凌宸1642 题目描述: With the 2010 FIFA World Cu ...
- PAT甲级:1152 Google Recruitment (20分)
PAT甲级:1152 Google Recruitment (20分) 题干 In July 2004, Google posted on a giant billboard along Highwa ...
- PAT乙级:1057 数零壹 (20分)
PAT乙级:1057 数零壹 (20分) 题干 给定一串长度不超过 105 的字符串,本题要求你将其中所有英文字母的序号(字母 a-z 对应序号 1-26,不分大小写)相加,得到整数 N,然后再分析一 ...
随机推荐
- idea新建maven项目后生成web.xml方法和添加到tomcat方法
idea新建maven项目后生成web.xml方法和添加到tomcat方法 参考:https://www.cnblogs.com/Liang-Haishan216/p/9302141.html 1.首 ...
- C# 接口练习
#define debug using System; using System.Collections; namespace ConsoleApp1 { interface IAnimal { in ...
- 1)BS和CS区别
(1)CS: 客户端服务器 BS: 浏览器和服务器 (2)二者区别: 微信就相当于 客户端服务器 同时 微信也有 网页版. BS灵活,不用下客户端,但是网页什么内容都有,就有可能将用户的信息泄 ...
- CGLIB原理及实现机制
https://blog.csdn.net/gyshun/article/details/81000997
- PAT甲级——1009 Product of Polynomials
PATA1009 Product of Polynomials Output Specification: For each test case you should output the produ ...
- css后续篇
5.盒模型 在css中,box model这一术语是用来设计和布局时使用的,在网页中显示一些方方正正的盒子,这种盒子就叫盒模型 盒模型有两种: 标准模型和IE模型(了解) 盒模型属性 width : ...
- 苹果为啥不愿意替美国FBI解锁,这是一种创新态度?
国外媒体报道,苹果计划对iPhone进行安全更新,最新版的iOS会在手机锁定一个小时后禁用手机充电和数据端口,这意味着,消费者丢失手机或者非正常离开iPhone之后,可以通过锁定手机,来避免手机数据被 ...
- 通俗易懂JSONP讲解
原文地址:http://www.cnblogs.com/dowinning/archive/2012/04/19/json-jsonp-jquery.html JSON的格式或者叫规则: JSON能够 ...
- K3CLOUD表关联
销售订单关联发货通知单 销售订单表 T_SAL_ORDER A T_SAL_ORDERENTRY B T_SAL_ORDERENTRY_LK C 发货通知单表 T_SAL_DELIVERYNOTICE ...
- Java 的 ArrayList 的底层数据结构
1. 数据结构--ArrayList源码摘要 ublic class ArrayList<E> extends AbstractList<E> implements List& ...