当前位置:网站首页>Write a method Sanjiao (a, B, c) to judge whether the three parameters can form a triangle. If not, throw an exception illegalargumentexception and display the exception information a, B, C "cannot fo
Write a method Sanjiao (a, B, c) to judge whether the three parameters can form a triangle. If not, throw an exception illegalargumentexception and display the exception information a, B, C "cannot fo
2022-04-22 07:18:00 【Gratifying clover (●  ̄ (エ)  ̄ ●)】
1、 Write a method sanjiao(a, b, c), Judge whether the three parameters can form a triangle , If not, throw an exception IllegalArgumentException, Display exception information a,b,c” Can't make a triangle ”, If it can be formed, the three sides of the triangle are displayed , Get the three integers entered on the command line in the method , Call this method , And catch the exception .
class SanJiao:
def sanjiao(self,a, b, c):
try:
if a + b > c and a + c > b and b + c > a:
print(' The three sides of the triangle are :{}、{}、{}'.format(a, b, c))
else:
raise Exception('IllegalArgumentException!')
except Exception as error:
print('Error:',error,'a,b,c” Can't make a triangle ”')
a = SanJiao()
print(' Case one :')
a.sanjiao(1, 2, 3)
print()
print(' The second case :')
a.sanjiao(3, 4, 5)

版权声明
本文为[Gratifying clover (●  ̄ (エ)  ̄ ●)]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220609573246.html
边栏推荐
猜你喜欢

Jenkins部署pm2

Matlab: remove audio signal noise

Jeecg project deployment notes

【SVN】Subversion安装使用笔记

Build ES6 development environment and compile in real time

MySQL学习笔记

微信浏览器无法长期保存cookie

Chip design how to prepare for the upcoming autumn recruitment and spring recruitment in the coming year?

定义一个抽象的Role类有姓名年龄性别爱好等成员变量要求尽可能隐藏所有变量(能够私有就私有)再通过Get()和Set()方法对各变量进行读写,其中龄必须在0到150岁性别必须是男或者女姓名必须是2个字

Process of stepping on the pit in the flutter environment
随机推荐
Pyhon3 batch merges M4S video files cached by BiliBili
Digital IC design and CS?
完成一个学生信息管理系统,系统练习面向对象、函数、字符串等知识。实现知识的综合应用。 使用类、函数、数据库等来实现
win10 anaconda安装cocotb
ASP.NET日常开发随手记------发送邮件
Nacos cluster configuration
假设成年人的体重和身高存在此种关系: 身高(厘米)-100=标准体重(千克) 如果一个人的体重与其标准体重的差值在正负5%之间,显示“体重正常”,其他则显示“体重超标”。编写程序,能处理用户输入的
ASP. Net daily development notes ---- parsing and transforming XML
Random库的8个函数
[bug notes] mounted is executed only once under keepalive
Shift left and right
Process of stepping on the pit in the flutter environment
定义类Shape作为父类,并在类中定义方法求周长和面积; (2)定义Shape子类圆形(circle),具有半径属性和常量PI,同时重写父类中的方法; (3)定义Shape子类长方形(rect
任选一小说网站,爬取任意一部小说,以记事本的形式保存。
SQLSERVER存储过程开发笔记----零碎问题以及关于操作文件的操作
机械设计知识点规划
Parseexception unparseable date time conversion exception
Matlab: female voice to male voice
MacOS installs redis and sets the service self start
How to become an IC Verification Engineer?