下述脚本是个简单的脚本,是学习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")