I am currently writing a short program for my intro to computer science course, and my code is returning "none" even though I am pretty sure my definitions are clear. Don't mind the bulky naming for my functions and stuff, its a course requirement. The objective of the code is to be able to choose a shape and then directly input the required information without a written prompt, and then the program will RETURN the area of the chosen shape. I have been breaking my teeth over this for the past few hours, playing with it, but my code is returning none regardless of what I do. Any advice? Please refrain from blatantly giving me new code because I can get in trouble for that, just perhaps point me in the direction of my problem.
import math
# the following functions are built to calculate each shape
def circle_area(rad):
return math.pi*rad**2
def rectangle_area(side_one, side_two):
return side_one*side_two
def triangle_area(edge):
return (math.sqrt(3)/4)*(edge**2)
# the following function as assigned using the above functions
def shape_area():
shape_choice = input("Choose shape (1=circle, 2=rectangle, 3=triangle):")
if shape_choice == 1 or 3:
length_one = input("")
elif shape_choice == 2:
length_two, length_three = input("")
if shape_choice == 1:
circle_area(length_one)
elif shape_choice == 2:
rectangle_area(length_two, length_three)
elif shape_choice == 3:
triangle_area(length_one)
elif shape_choice != 1 or 2 or 3:
return None
I'm not sure why all my code isn't going into the specific code gray box, but I hope my code is more or less clear.