Python Forum
What am i doing wrong - math tool box
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What am i doing wrong - math tool box
#1
So I was told to create a math tool box which I have but for some reason when I actually enter a value nothing happens and or my code tells me not valid choice try again. I do not need help with the assignment as I am already almost done BUT I don't get why this is happening. Also this is my first post hopefully I'm following all the rules.

ans=True
while ans:
    print("""
    1.Square
    2.Rectangle
    3.Triangle
    4.Circle
    5.Exit the program
    """)
    ans=input("What would you like to do?")
    if ans==1:
        print("""Square is selected.""")
        side = input("Now input side")
        print ("Area is"),side*side
        print ("Circumference is"),4*side
    elif ans==2:
        print("Rectangle is selected")
        length = input("Now input length")
        breadth = input("Now input breadth")
        print ("Area is"),length*breadth
        print ("Circumference is"),2*(length+breadth)
    elif ans==3:
        print("Triangle is selected")
        side1 = input("Now input side 1")
        side2 = input("Now input side 2")
        side3 = input("Now input side 3")
        height = input("Now input height ")
        base = input("Now input base")
        print ("Area is"),0.5*base*height
        print ("Circumference is"),(side1+side2+side3)
    elif ans==4:
        print("Circle is selected")
        radius = input("Now input radius")
        print ("Area is"),3.14*radius*radius
        print ("Circumference is"),(2*3.14*radius)


    elif ans==5:
        print("Goodbye")
        ans = None
    else:
        print("Not valid choice try again")
Reply


Messages In This Thread
What am i doing wrong - math tool box - by TJOm - Apr-18-2018, 06:59 PM
RE: What am i doing wrong - math tool box - by TJOm - Apr-18-2018, 07:37 PM
RE: What am i doing wrong - math tool box - by TJOm - Apr-18-2018, 07:45 PM
RE: What am i doing wrong - math tool box - by TJOm - Apr-18-2018, 08:06 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020