python判断能否组成三角形_python 3.2 调用自定义函数,输入三条边,判断是否能组成三角形...

下述脚本是个简单的脚本,是学习python 3.2函数时编写的。拿出来,希望大家提些建议,以便改进。

#-*- encoding: utf-8 -*-

'''

Created on 2011-7-26

Modified on 2011-7-27

Debug on 2011-7-28

@author: songwenjun

'''

def istrigon(x,y,z):

if (x == 0) or (y == 0) or (z == 0):

print("The game is over")

exit()

if x < 0 :

x = input("The number of side inefficacy,so enter the first of side again, please:")

x = float(x)

if y < 0 :

y = input("The number of side inefficacy,so enter the second of side again, please:")

y = float(y)

if z < 0 :

z = input("The number of side inefficacy,so enter the third of side again, please:")

z = float(z)

if (x >= (y + z)) or (y >= (x + z)) or (z >= (x + y)):

return False

if (x <= (abs(y - z))) or (y <= (abs(x - z))) or (z <= (abs(x - y))):

return False

return True

iswhile = True

print("The game is order to checking three sides for trigon")

while iswhile :

print("Enter three number for side of trigon please:")

a = input("Enter the first of side, please:")

a = float(a)

b = input("Enter the seconde of side, please:")

b = float(b)

c = input("Enter the third of side, please:")

c = float(c)

if istrigon(a,b,c) :

print("it's ok!")

else :

print("Sorry,it isn't trigon")

isgoon = input("Do you want to go on? 1 is again; 0 is exit programme:")

isgoon = int(isgoon)

if isgoon == 1 :

continue

else :

iswhile = False

print("Done1")

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值