MENU DRIVEN PROGRAM IN PYTHON WITH MAIN MENU SCREEN AND TASK REQUIREMENT PROGRAM
1. WHAT ARE MENU DRIVEN PROGRAM ?
menu driven programs that is programs were under run the user gets a menu. so exactly as I said it. the the program is run you get a list of options and use it it's normally each option is a number associated with it the user types in that number.
2. EXAMPLE OF MENU DRIVEN PROGRAM
print("Enter A :")
a = int(input())
print("\nEnter B :")
b = int(input())
print("\nChoose Options To Perform : ")
print("\n1.Addition")
print("\n2.Subtraction")
print("\n3.Multiplication")
print("\n4.Division")
print("\n\nEnter Your Choice :")
choice = int(input())
if choice==1 :
print("\nAddition of A + B is : ",a+b)
elif choice==2 :
print("\nSubtraction of A - B is : ",a-b)
elif choice==3 :
print("\nMultiplication of A * B is : ",a*b)
elif choice==4 :
if(b == 0) :
print("b cannot be 0(Zero) for Division operation")
else :
print("\nDivision of A / B is : ",a/b)
else :
print("Invalid Choice")Output :
Enter A :20
Enter B :30
Choose Options To Perform :
1.Addition :
2.Subtraction :
3.Multiplication :
4.Division :
Choice is : 1
Addition of A + B is : 50
Enter A :20
Enter B :30
Choose Options To Perform :
1.Addition :
2.Subtraction :
3.Multiplication :
4.Division :
Choice is : 1
Addition of A + B is : 50
MAKE a Main Menu screen, based on the task requirements. You can also go ahead and define all the necessary functions that you will need to create to provide an overview of the problem and tasks ahead
#Form Tutor Management System
import sys #this allows you to use the sys.exit command to quit/logout of the application
def main():
login()
def login():
username="formtutor"
password="teacherypass"
print("Enter username : ")
answer1=input()
print("Enter password : ")
answer2=input()
if answer1==username and answer2==password:
print("Welcome - Access Granted")
menu()
def menu():
print("************MAIN MENU**************")
#time.sleep(1)
print()
choice = input("""
A: Enter Student details
B: View Student details
C: Search by ID number
D: Produce Reports
Q: Quit/Log Out
Please enter your choice: """)
if choice == "A" or choice =="a":
enterstudentdetails()
elif choice == "B" or choice =="b":
viewstudentdetails()
elif choice == "C" or choice =="c":
searchbyid()
elif choice=="D" or choice=="d":
producereports()
elif choice=="Q" or choice=="q":
sys.exit
else:
print("You must only select either A,B,C, or D.")
print("Please try again")
menu()
def enterstudentdetails():
pass
#Teacher will enter student details manually
#These will be appended to the csv file
def viewstudentdetails():
pass
#Teacher can press a button to view all students at a glance
def searchbyid():
pass
#Teacher can input an ID number and display the relevant student's details
def producereports():
pass
#Teacher can produce clever reports such as:
#a) list of names of males and email addresses (to email a reminder about boys football club)
#b) list of names of females in specific postcode (to remind them of a girls coding club in the area)
#c) list of all names, birthdays and addresses (to send out birthday cards!)
#the program is initiated, so to speak, here
main()
THANK YOU SO MUCH .....
Good to understand
ReplyDeleteNice explanation and easy to understand
ReplyDelete