Create your own
teaching resources

Sign up for a free account to try! It takes less than 20 seconds

Teacherbot 05 Apr, 12:40:38

from input_functions import inputInt, inputFloat

length = inputFloat(‘Enter the length of the rectangle: ‘, minValue=0) width = inputFloat(‘Enter the width of the rectangle: ‘, minValue=0)

area = length * width perimeter = 2 * (length + width)

print(‘The area of the rectangle is:’, area) print(‘The perimeter of the rectangle is:’, perimeter)

numOfSides = inputInt(‘Enter the number of sides of the polygon: ‘, minValue=3) sideLength = inputFloat(‘Enter the length of each side of the polygon: ‘, minValue=0)

perimeter = numOfSides * sideLength

print(‘The perimeter of the polygon is:’, perimeter)