#This program will ask for a shape and measurement. It will calculate the chosen shapes perimiter and area based on the measurement given. import math #Collect input name = input('What is your name? ') print(f'Kia ora {name}') keep_going = '' print('This program calculates the perimiter and area of different shapes.') while keep_going == '': shape = input(f'{name}, what shape do you want to select? square, triangle, rectangle or circle? press "s" for square, "t" for triangle, "r" for rectangle or "c" for circle ') if shape == 's': length = float(input('What is the length of your square? ')) measurement = input('What units of measurement are you using? ') perimeter = length + length + length + length area = length * length print(f'The perimeter of a square with a length of {length} {measurement} is {perimeter} {measurement} and the area is {area} {measurement}².') elif shape == 't': length_a = float(input('What is length "a" of your triangle? ')) length_b = float(input('What is length "b" of your triangle? ')) length_c = float(input('What is length "c" of your triangle? ')) measurement = input('What units of measurement are you using? ') perimeter = length_a + length_b + length_c semi_perimeter = perimeter / 2 area = math.sqrt(semi_perimeter * (semi_perimeter - length_a) * (semi_perimeter - length_b) * (semi_perimeter - length_c)) print(f'The perimiter of a rectangle with a length "a" of {length_a} {measurement}, a length "b" of {length_b} {measurement} and length "c" of {length_c} {measurement} is {perimeter} {measurement} and the area is {area} {measurement}².') elif shape == 'r': length = float(input('What is the length of your rectangle? ')) width = float(input('What is the width of your rectangle? ')) measurement = input('What units of measurement are you using? ') perimeter = width + length + width + length area = length * width print(f'The perimiter of a rectangle with a length of {length} {measurement} and a width of {width} {measurement} is {perimeter} {measurement} and the area is {area} {measurement}².') elif shape == 'c': radius = float(input('What is the radius of your circle? ')) measurement = input('What units of measurement are you using? ') circumference = 2 * 3.14 * radius area = 3.14 * (radius * radius) print(f'The circumference of a circle with a radius of {radius} {measurement} is {circumference} {measurement} and the area is {area} {measurement}².') else: print('You have chosen an invalid shape') keep_going = input('Do you want to find measurements for another shape? Press enter if yes, type no if no.') #Display output print('The program has ended')