Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to calculate the area and perimeter of a shape in python

Shape = input("what shape do you have: ")

if Shape == 'square':
	Kind = input("you want the area perimeter : ")
	if Kind == 'area':
		width = int(input("What's the width of the area? : "))
		height = int(input("What's the height of the area? : "))
		calculation = width * height
		print(f"It's {calculation}")
	if Kind == 'perimeter':
		width = int(input("What's the width of the perimeter? : "))
		calculation = width * 4
		print(f"It's {calculation}")
if Shape == 'rectangle':
	Kind = input("you want the area perimeter : ")
	if Kind == 'area':
		width = int(input("What's the width of the area? : "))
		height = int(input("What's the height of the area? : "))
		calculation = width * height
		print(f"It's {calculation}")
	if Kind == 'perimeter':
		width = int(input("What's the width of the area? : "))
		height = int(input("What's the height of the area? : "))
		calculation = width * 2 + height * 2
		print(f"It's {calculation}")
		
 
PREVIOUS NEXT
Tagged: #calculate #area #perimeter #shape #python
ADD COMMENT
Topic
Name
1+9 =