Python判断三角形
来源:互联网 发布:淘宝微淘公布在哪里看 编辑:程序博客网 时间:2024/06/06 21:41
#Copyright (c)2017, 东北大学软件学院学生 # All rightsreserved #文件名称:a.py # 作 者:孔云 #问题描述:编写程序,从键盘输入三条边,判断是否能够构成一个三角形。#问题分析:组成三角形的条件是任意两边之和大于第三边,如果条件成立,则能构成三角形。条件表达式中的多个条件必须全部成立,条件之间使用and运算符连接。代码如下:side1=float(input("the first side of triangle:"))side2=float(input("the second side of triangle:"))side3=float(input("the thrid side of triangle:"))if(side1+side2>side3)and(side2+side3>side1)and(side3+side1>side2): print (side1,side2,side3,"is sides of triangle")else: print (side1,side2,side3,"is not sides of triangle")
运行结果如下:
注:在这注意的是条件表达式中使用and运算符,而不是&!!!
阅读全文
0 0
- Python判断三角形
- 判断三角形
- 判断三角形
- 判断三角形
- 三角形判断
- 判断三角形
- 判断三角形
- 判断三角形
- 三角形判断
- 判断三角形
- 判断三角形
- 三角形判断
- 三角形判断
- 三角形判断
- 三角形判断
- 判断三角形
- 判断三角形
- 判断三角形
- 比较字符串CompareTo的用法及注意
- Windows安装npm及cnpm
- SpringBoot环境搭建和返回JSON 字符串
- linux centos7 安装jdk、tomcat、mysql、笔记
- 关于Timer定时器
- Python判断三角形
- 【LeetCode算法练习(C++)】String to Integer (atoi)
- Python多线程编程之thread和threading
- The 36th ACM/ICPC Asia Regional Shanghai Site 4016(dfs+剪枝)
- BZOJ 2005 能量采集 (Mobius反演)
- linux命令之jps
- Android 6.0+ 实现白色状态栏(白底黑字)
- 代码质量管理:SonarQube + Jenkins Pipeline配置
- Centos 7安装完成后需要做的事情