Hey everyone! I'm new to programming and currently working on a school project where I need to create a menu-driven Python program. The program should allow the user to select a geometric shape, input the required dimensions, and then display both the area and perimeter (or circumference for circles). After showing the results, it should loop back to the menu until the user types 'quit' (case-insensitive).
Here are the requirements I need to follow:
- Display a menu each time with these options:
• Square
• Rectangle
• Rhombus
• Circle
• Trapezoid
• Quit (to exit the program)
- Accept the user's choice as text.
- After displaying results, show the menu again.
- Use functions: at least one for each shape and one main() function for the loop.
- Include the if __name__ == '__main__': main() structure.
I've included the code I've written so far, but I'm running into issues specifically with calling the main() function correctly. When I try to run it under the if __name__ == '__main__': section, it doesn't execute. However, calling main() directly works fine. Additionally, when I run the main() function, it doesn't show results until I quit the program. I would really appreciate any help or tips to fix these problems!
3 Answers
Hey! It looks like you're not actually calling the functions for the circle, rhombus, and trapezoid in your main loop; you're just referencing them. Make sure you add the parentheses when calling them, like `calc_circle()` instead of just `calc_circle`. That should solve your first issue!
I noticed a few things that might help:
1. Are you using the correct quotes? You should use straight quotes (`"` and `'`) instead of typographic ones.
2. Check your indentation; if the loop keeps going without printing results, there might be an indentation issue.
3. Your quit checks could be simplified. You only need to check `choice.lower() == 'quit'` since that will handle all variations like 'QUIT' and 'Quit'. So, you can get rid of the other checks.
With these changes, your code should work as expected!
I’ll double-check those once I'm finished eating! I think the quotes might just be a quirk from how I'm typing on my phone.
How are you running your program? Are you using an IDE with a built-in play button, or do you save your file and execute it through the terminal? Everything you've typed (with proper quotes and parentheses) should work fine in either case!
I was actually about to update my post to say that I realized I had an indentation issue in my main loop. Thanks for the reminder!

Ah, that's my mistake! I forgot to include the parentheses in my post. I’ve got it correct in my actual code.