~ Creating a Main Menu in Python


Sample Project - Form Tutor Management System

*Teachers with subscriptions will have access to all worked solutions and python code. This sample project is based on OCR GCSE NEA Task 1

CHALLENGE: 

Create 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

SUGGESTED SOLUTION / CODE: 

Note: See if you can do better (and you should be able to). The solutions provided are basic, and allow for discussion on possible alternative methods and solutions.

#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()


Analyse

Write your own summary of the problem. What are your objectives? List the success criteria

Design Tools

Designing something or writing out some pseudocode before you actually write code is always a good idea! Get in to the habit of doing so! You can draw your flowchart here and screenshot it.

Try it yourself

Testing Table

You may want to read a little about Testing first. A teacher may go through some examples with you. Feel free to fill in the test table here, and screenshot it in to your powerpoint. Testing is absolutely essential once you have created a program!
Test No. Description Test Data(input) Expected Outcome Actual Outcome Further Action?
1
2
3
4
5
Coming soon!