谁是学COMPUTER的啊,进来帮帮忙吧,谢谢了

雨过天晴

Fly Away!^_^
注册
2003-10-01
消息
2,357
荣誉分数
0
声望点数
0
PROJECT,写了个程式
总是出现错误
谁帮帮忙看错在哪里了啊
谢谢谢谢
def Area_Square(s): return s*s
def Area_Rectangel(x,y): return x*y
def Area_Circle(r): return 3.14*r*r
def Perimeter_Square(s): return 4*s
def Perimeter_Rect(x,y): return 2*x + 2*y
def Perimeter_Circle(r): return 2* 3.14 * r
print "Calculation menu"
print "1) Area(Square) "
print "2) Area(Rectangle)"
print "3) Area(Circle)"
print "4) Perimeter(Square)"
print "5) Perimeter (Rectangel)"
print "6) Perimeter(Circle)"
print "7) Exit"
a=input("Input menu choice(1,2,3,4,5,6 or 7)?")
while a>7 : a=input("Input menu choice(1,2,3,4,5,6 or 7)?")
if a==1 :
print "You have chosen Area(Square)"
s=input("Input Length")
print "Area is", Area_Square(s)
elif a==2 :
print "You have chosen Area(Rectangel)"
x=input("Input width")
y=input("Input length")
print "Area is ", Area_Rectangle(x,y)
elif a==3 :
print "You have chosen Area(Circle)"
r=input("Input Radius")
print "Area is ", Area_Circle(r)
elif a==4 :
print "You have chosen Perimeter(Square)"
s=input("Input Length")
Print "Perimeter is ", Perimeter_Square(s)
elif a==5 :
print "You have chosen Perimeter(Rectangel)"
x=input("Input width")
y=input("Input length")
Print "Perimeter is ", Perimeter_Rectangel(x,y)
elif a==6 :
print "You have chosen Perimeter(Circle)"
r=input("Input Radius")
Print "Perimeter is ", Perimeter_Circle(r)
else : break
 
看起来像C
啥语言??
知道你要写啥东西,不过不知道是啥语言
 
这个是题55555
拜托了
Rewrite the area.py program (shown below or in the Functions section of the tutorial) so that it has separate functions for the perimeter and area of a square, a rectangle, and a circle. (3.14 * radius**2). This program should include a menu interface which has as one of its choices 'exit the program'.

SAMPLE PROGRAM EXECUTION

Area.py
#This program calculates the perimeter and area of a rectangle
print "Calculate information about a rectangle"
length = input("Length:")
width = input("Width:")
print "Area",length*width
print "Perimeter",2*length+2*width

SAMPLE OUTPUT (not including author/program information)

CALCULATIONS MENU
1) AREA (SQUARE)
2) AREA (RECTANGLE)
3) AREA (CIRCLE)
4) PERIMETER (SQUARE)
5) PERIMETER (RECTANGLE)
6) PERIMETER (CIRCLE)
7) EXIT
INPUT MENU CHOICE (1,2,3,4,5,6 OR 7)? 2
YOU HAVE CHOSEN AREA (RECTANGLE)
INPUT WIDTH? 8
INPUT LENGTH? 4
AREA IS 32
INPUT MENU CHOICE?
 
??看不出有什?邋锗,你用什??篦?的?Debug 真什??
 
老师让我们用PYTHON
就是在>>> while a>7: a=raw_input("Input menu choice(1,2,3,4,5,6 or 7)?")
之后
就一直是Input menu choice(1,2,3,4,5,6 or 7)?
我快疯了
 
代码:
def Area_Square(s): 
print s*s

def Area_Rectangel(x,y): 
print x*y

print """
CALCULATIONS MENU
1) AREA (SQUARE)
2) AREA (RECTANGLE)
3) AREA (CIRCLE)
4) PERIMETER (SQUARE)
5) PERIMETER (RECTANGLE)
6) PERIMETER (CIRCLE) 
7) EXIT
"""
while True:
x = int(raw_input("INPUT MENU CHOICE (1,2,3,4,5,6 OR 7)?"))

if x in range(7):
     if x = 1 
        s = int(raw_input("YOU HAVE CHOSEN AREA (SQUARE)")
        Area_Square(s)
        break

     elif x = 2
        print "YOU HAVE CHOSEN AREA (RECTANGLE)"
        x = int(raw_input("Input width")
        Area_Rectangel(x,y)
        break

     else
        break
else
    break
 
你不能那么写的
以为a的值一直没有initialized

我照着官方主页写的,希望能运行
 
上头那个改成这个
def Area_Square(s):
print "Area",s*s

def Area_Rectangel(x,y):
print "Area",x*y
其他类似
 
啊不,a>7 = a大于7
当a大于7时候做下面这些code.....
which is definitely ur logical error la
 
:crying: :crying: :crying:
大恩不言谢
可是,我还是要说谢谢,谢谢了
 
我觉得似乎一看是判断x的那些应该用pass,hmmmmmmmm,break的话,while就停了,which is not good
pass或者continue,你test一下看看
 
Fixed some errors. Good luck!


最初由 雨过天晴 发布
这个是题55555
拜托了
Rewrite the area.py program (shown below or in the Functions section of the tutorial) so that it has separate functions for the perimeter and area of a square, a rectangle, and a circle. (3.14 * radius**2). This program should include a menu interface which has as one of its choices 'exit the program'.

SAMPLE PROGRAM EXECUTION

Area.py
#This program calculates the perimeter and area of a rectangle
print "Calculate information about a rectangle"
length = input("Length:")
width = input("Width:")
print "Area",length*width
print "Perimeter",2*length+2*width

SAMPLE OUTPUT (not including author/program information)

CALCULATIONS MENU
1) AREA (SQUARE)
2) AREA (RECTANGLE)
3) AREA (CIRCLE)
4) PERIMETER (SQUARE)
5) PERIMETER (RECTANGLE)
6) PERIMETER (CIRCLE)
7) EXIT
INPUT MENU CHOICE (1,2,3,4,5,6 OR 7)? 2
YOU HAVE CHOSEN AREA (RECTANGLE)
INPUT WIDTH? 8
INPUT LENGTH? 4
AREA IS 32
INPUT MENU CHOICE?
 
后退
顶部