I'm new to programming and I'm trying to shorten a part of my program using user-defined functions, but I'm kinda lost. How do I shorten this or make it more efficient using user-defined functions?
import math
while True:
print('#####################')
print('# GEOMETRIC OBJECTS #')
print('#####################')
print('[1] Circle')
print('[2] Triangle')
print('[3] Rectangle')
print('[4] Cone')
print('[5] Triangular Pyramid')
print('[6] Pyramid')
print('[7] Exit')
option = input('Option: ')
if option == '7':
print('You have exited.')
exit()
if option == '1': #Circle Geometric Object
print('You have chosen circle.')
print('')
print('================')
print(' CIRCLE ')
print('================')
print('[1] Enter the length of the radius')
print('[2] Area')
print('[3] Circumference')
print('[4] Back to main menu')
optionCircle = input('Option: ')
if optionCircle == '4':
continue
if optionCircle == '1':
print('Enter the length of the radius.')
Rad = float(input('> Radius: '))
while True:
print('')
print('================')
print(' CIRCLE ')
print('================')
print('[1] Enter the length of the radius')
print('[2] Area')
print('[3] Circumference')
print('[4] Back to main menu')
optionRadius = input('Option: ')
if optionRadius == '2':
area = math.pi * Rad * Rad
print('')
print('> The area of the circle with a radius of ' + str(Rad) + ' is ' + str(area))
elif optionRadius == '3':
circum = 2 * math.pi * Rad
print('')
print('> The circumference of the circle with a radius of ' + str(Rad) + ' is ' + str(circum))
else:
break