2016-10-05 2 views
-6
print ("Welcome to my Area Calculator") 
i=raw_input("Please enter the shape whose Area you want to calculate(square/rectangle/right angled triangle/rhombus/parallelogram): ") 
my_list=["square","rectangle","triangle","right angled triangle","rhombus","parallelogram"] 
if i in my_list: 
    if i=="square": 
     s=float(input("What is the side of the square: ")) 
     print "Area of the square is : ", s**2 
    elif i=="rectangle": 
     l=float(input("What is the length of the rectangle: ")) 
     b=float(input("What is the breadth of the rectangle: ")) 
     print "Area of the rectangle is : ", l*b 

    elif i=="right angled triangle": 
     base1=float(input("What is the base of the triangle: ")) 
     height1=float(input("What is the height of the triangle: ")) 
     print "Area of the triangle is : ", 0.5*base1*height1 
    elif i=="rhombus": 
     d1=float(input("What is the length of the 1st diagnol of the rhombus: ")) 
     d2=float(input("What is the length of the 2nd diagnol of the rhombus: ")) 
     print "Area of the rhombus is : ", 0.5*d1*d2 
    elif i=="parallelogram": 
     base=float(input("What is the length of 1 side of the parallelogram: ")) 
     height=float(input("What is the length of the other side: ")) 
     print "Area of the parallelogram is : ", height*base 
    print "Thank you so much for using my area calculator" 

ответ

0

Спросите пользователя, если он хочет продолжать, положить его в булевой переменной, положить весь код в цикле в то время как с этим булево как условие
Дон» t забудьте установить это логическое значение в true

2

Сделать вашу программу полностью функцией, а затем выполнить ее внутри цикла.

while(option != 'yes'): 
    Program() 
    userInput() 
+0

спасибо, но может у вас показать пример – amith1198

Смежные вопросы