python - if-statement depending on input -
i trying create "simple" way ask person shape find area of. find area of shape based on input. using python 2.7.3. here have far:
from math import pi c = "" r = "" x = (input("do have [r]ectangle or [c]ircle? ")) # answer r or c if x == "r": l = (int(input("what length of rectangle? "))) w = (int(input("what width of rectangle? "))) print( l * w ) elif x == "c": r = (int(input("what radius of circle? "))) print( r ** 2 * pi) else: print("please enter request in lower case. ")
from math import pi # use raw input (raw_input()) inputs... input() eval(input()) # how ask input simple problem x = (raw_input("do have [r]ectangle or [c]ircle? ")) # answer r or c # use .lower() allow upper or lowercase if x.lower() == "r": l = (int(raw_input("what length of rectangle? "))) w = (int(raw_input("what width of rectangle? "))) print( l * w ) elif x.lower() == "c": r = (int(raw_input("what radius of circle? "))) print( r ** 2 * pi) else: print("you didn't enter r or c.")