A menu driven program in python is a program that obtains a choice from a user by displaying the menu. Then, it will perform some operations and print the result according to the user’s choice.
If you are looking for menu driven program for a calculator Click Here
Menu Driven Program in Python using while loop
Write a menu-driven program to find the area of a circle, square, and rectangle in python. This post will make a menu-driven program using a while loop and simple if-else statements for the following operations:
- Area of Circle
- Area of Rectangle
- Area of square
- Exit
while True:
print("Menu Driven Program")
print("1.Area of Circle")
print("2.Area of Rectangle")
print("3.Area of Square")
print("4.Exit")
choice=int(input("Enter your choice:"))
if choice==1:
radius=int(input("Enter radius of Circle:"))
print("Area of Circle",3.14*radius*radius)
elif choice==2:
length=int(input("Enter length of Rectangle:"))
breadth=int(input("Enter breadth of Rectangle:"))
print("Area of Rectangle:",length*breadth)
elif choice==3:
side=int(input("Enter side of Square:"))
print("Area:",side*side)
elif choice==4:
break
else:
print("Wrong Choice")
repeat=input("Do you want to continue? (y/n)")
if repeat=='n'or repeat=='N':
break
Output:
Menu Driven Program
1. Area of Circle
2. Area of Rectangle
3. Area of Square
4. Exit
Enter your choice:3
Enter the side of Square:5
Area: 25
Quick algorithm:
- Print the menu on the screen.
- Input the choice from the user.
- According to their choice, display the area using the if-else statement.

If you cannot run this program or get an error, let me know in the comment section. You can also message us on our Instagram account. We will send you a meet link and teach you every line of code free of cost.
Related posts: Palindrome Program in Python
Factorial Program in Python using for loop
Video Solution
Menu Driven Program in Python using functions
In this program, we will create a python program for class 12 in which we will calculate the area of different shapes like circles, squares, and rectangles using functions.
def circle(radius):
print("Area of Circle",3.14*radius*radius)
def rectangle(length,breadth):
print("Area of Rectangle:",length*breadth)
def square(side):
print("Area:",side*side)
while True:
print("Menu Driven Program")
print("1.Area of Circle")
print("2.Area of Rectangle")
print("3.Area of Square")
print("4.Exit")
choice=int(input("Enter your choice:"))
if choice==1:
radius=int(input("Enter radius of Circle:"))
circle(radius)
elif choice==2:
length=int(input("Enter length of Rectangle:"))
breadth=int(input("Enter breadth of Rectangle:"))
rectangle(length,breadth)
elif choice==3:
side=int(input("Enter side of Square:"))
square(side)
elif choice==4:
break
else:
print("Wrong Choice")
Output:
Enter your choice:1
Enter radius of Circle:5
Area of Circle 78.5
This Menu-driven program in python using functions is essential for class 12th students. One question about this program can come from the CBSE board, so prepare well for it. If you have any doubt, let me know in the comment section.
We can also call this program a python menu loop because we will display the menu in a loop until the user wants to exit.
Questions Related to this Program
Explain a menu-driven program with an example?
Menu-driven program using if-else, which will perform operations according to the user’s choice. Here are examples of menu-driven programs.
- Menu-driven program to calculate the area/perimeter of different shapes.
- Menu-driven program to perform simple arithmetic operations (create a simple calculator) like adding two numbers in python and subtraction.
How do you exit a menu-driven program?
We have to use the break statement to exit from the loop. When users want to leave the loop, They will choose the option to exit, and in that “if condition,” we will write a break statement.
Menu Driven Program for Class 12th Students [CBSE BOARD]
If you cannot run this program or get an error, let me know in the comment section. You can also message us on our Instagram account. We will send you a meet link and teach you every line of code free of cost.
We will make a program that helps us calculate the area of shapes according to the user’s choice. The user will decide whether he wants to get the area of a square or a circle, depending on his/her choice.
We will make this program using an infinite while loop which will terminate as soon as users choose the option to exit. We will store his choice in a variable, which tells us about his choice so that we can make our if-else statements.
Then we ensure that we cover all the conditions that our menu provides. However, there will be another case when the user provides input not in our menu.
For example, you go to Domino and order momos unavailable on their menu. So, they will tell you “Wrong choice” and order something else shown on their menu. Hence we will add an else statement that will print the wrong choice.
About this program: This is a menu-driven program in python using a while loop and functions. It is an essential menu-driven program for board practical. You can comment below if you have any queries related to this post.
Please subscribe to our newsletter to connect with us. If you like this post, then please share this post with your friends.
how can we make the loop run again to accept the input if input is "Wrong Choice"
while True:
dine=eval(input("Please type 1 for Drive-Thru ; 2 for Dine-in ; 3 for Carry-out/Delivery"))
if dine==1:
dine_type="Drive-Thru"
elif dine==2:
dine_type="Dine-in"
elif dine==3:
dine_type="Carry-out/Delivery"
else:
print("Wrong Choice")
is def compulsary for structure progamming?
No, it's not compulsory to use functions for structure programming.
We break complex programs into small tasks using functions.
To organize our programs in python we use functions.
Develop menu driven program for library book management without using def function
Very informative and educative site
Thanks 😊
Ok
What will be the flowchart for the above program?
We will be uploading it soon. Please text us on instagram for the same.
Great website
Thanks ❤️
Thanks for this post, great content.
Welcome, please fill our feedback form
I have an assignment
I have an assignment to write a code can you help me ?
Ya Sure
Hellо, just wanted to telⅼ you, Ӏ enjoyeԀ this post.
It was inspiring. Keep on posting!
Thankyou so much!!!
Hello, Νeat post. There’s a problem along with your website in internet explorer, might test tһis?
IE nonetheless is the marketрlace chief and a good section of other folks will omit your fantastic writіng because of this problem.
internet explorer is officially dead
I’ve bеen browsing online more than three hours toԁay, yet I
never found any interesting article like yours. It’s pгetty worth enough for me.
In my vіew, if all webmasters and bloggers mɑde good content аs yߋu
did, the ѡeЬ wilⅼ be much more useful than ever before.