New course! Every coder should learn Generative AI!
Try a free lesson0
# this is how i would do it
# for creating the area of a circle
from math import py
#how to calculate square
x * x
#how to calculate rectangle
x*y
putting it all in a simple program:
def square(x)
x = input ("enter the length of the square: ")
return x*x
def rectangle (x, y):
x = input ("length: ")
y = input ("width: ")
return x*y
def circle (r):
r = input ("radius: ")
x = py*r
return x*x
A = input ("type in square, rectangle or circle")
if A == "square":
square (x)
elif A == "rectangle":
rectangle (x, y)
elif A == "circle":
circle (r)