calculator - Python Calculating the perimeter of a circle -


i working on area calculator in python, , seems ok,...until calculating perimeter of circle...

can point me in right direction?

import math math import pi  menu = """ pick shape(1-3):    1) square (area)    2) rectangle (area)    3) circle (area)    4) square (perimeter)    5) rectangle (perimeter)    6) circle (perimeter)    7) quit """ shape = int(input(menu)) while shape != 7:    if shape == 1:       length = float(input("length: "))       print( "area of square = ", length ** 2 )    elif shape == 2:       length = float(input("length: "))       width = float(input("width: "))       print( "area of rectangle = ", length * width )      elif shape == 3:       area = float(input("radius: "))       circumference = float(input("radius: "))       print( "area of circle = ", pi*radius**2 )    elif shape == 4:       length = float(input("length: "))       print( "perimeter of square = ", length *4 )    elif shape == 5:       length = float(input("length: "))       width = float(input("width: "))       print( "perimeter of rectangle = ", (length*2) + (width*2))      elif shape == 6:       circumference = float(input("radius: "))       print( "perimeter of circle = ", 2*pi*radius)     shape = int(input(menu)) 

replace variable circumference radius.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -