0% found this document useful (0 votes)
54 views10 pages

CS - RARE-TERM1-class 11

The document describes a menu-driven program for an attendance record system in Python. It includes functions for the main menu, searching records, inputting student details, and storing new records. The main menu uses a loop to display options and call the appropriate functions, like showing all records, adding a new one, searching, or exiting. Student details like name, ID number, and attendance status are input and stored in a text file. The flowchart shows the program flow, starting the program, reading a choice, and executing the corresponding function until exiting.

Uploaded by

Rockstar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views10 pages

CS - RARE-TERM1-class 11

The document describes a menu-driven program for an attendance record system in Python. It includes functions for the main menu, searching records, inputting student details, and storing new records. The main menu uses a loop to display options and call the appropriate functions, like showing all records, adding a new one, searching, or exiting. Student details like name, ID number, and attendance status are input and stored in a text file. The flowchart shows the program flow, starting the program, reading a choice, and executing the corresponding function until exiting.

Uploaded by

Rockstar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Computer Science

Rare Project

Name: Shambhavi Jha


Class/Sec: 11 E
What are Menu Driven programs?
Menu-Driven Program is a program that gets input from a user by showing the options list,
known as the menu, from which the user chooses their option. Systems processing the Menu-
Driven programs are ordinary, starting from washing machines controlled by Microprocessors to
Automated Teller Machines (ATMs).

Benefits of Menu-Driven systems


The Menu-Driven Systems are beneficial in two ways: At first, input is taken by the single
keystrokes, which reduces the chance of the system too prone to user error. Secondly, Menu-
Driven Systems limits the characters range resulting in the way where the entered input becomes
unambiguous. Hence, these two characteristics make the whole system pretty user-friendly.

How does a menu-driven program work?


1. Print out a menu with numbered options
2. Let the user enter a numbered option
3. Depending on the option number the user picks, run a function specific to that action. For
now, your function can just print out that its being run.
4. If the user enters in something invalid, it tells the user they did so, and re-display the
menu
5. Use a dictionary to store menu options, with the number of the option as the key, and the
text to display for that option as the value.
6. The entire menu system should run inside a loop and keep allowing the user to make
choices until they select exit/quit, at which point your program can end.

 Algorithm for Menu Driven Programs:


Step 1: Start the program.
Step 2: Read choice and num.
Step 3: Repeat till a valid choice.
Step 3a: If choice is 1
                     Execute the required function or procedure
Step 3b: If choice is 2
                     Execute the required function or procedure
Step 3c: If choice is 3
                     Execute the required function or procedure
Step 4: Stop the program.
ATTENDENCE RECORD SYSTEM
PYTHON CODE FOR ATTENDENCE RECORD SYSTEM:

# DPS ATTENDENCE RECORD


# printing the heading of the program
print( "WELCOME TO THE DPS ATTENDENCE RECORD")

# creating a .txt file to store contact details


filename = "dps_attendence_recod.txt"
myfile = open(filename, "a+")
myfile.close

# defining main menu


def main_menu():
print( "\nMAIN MENU\n")
print( "1. Show all existing attendence records")
print( "2. Add a new Record")
print( "3. Search the existing Record")
print( "4. Exit")
choice = input("\nEnter your choice: ")
if choice == "1":
myfile = open(filename, "r+")
filecontents = myfile.read()
if len(filecontents) == 0:
print( "\nThere is no record of attendence.")
else:
print(filecontents)
myfile.close
enter = input("\nPress Enter to continue ...")
main_menu()
elif choice == "2":
newcontact()
enter = input("\nPress Enter to continue ...")
main_menu()
elif choice == "3":
searchcontact()
enter = input("\nPress Enter to continue ...")
main_menu()
elif choice == "4":
print("\nThank you for filling the attendence!!!")
else:
print( "Please provide a valid input!\n")
enter = input( "\nPress Enter to continue ...")
main_menu()

# defining search function


def searchcontact():
searchname = input( "\nEnter First name for Searching contact record: ")
remname = searchname[1:]
firstchar = searchname[0]
searchname = firstchar.upper() + remname
myfile = open(filename, "r+")
filecontents = myfile.readlines()

found = False
for line in filecontents:
if searchname in line:
print( "Your Required Contact Record is:", end = " ")
print( line)
found = True
break
if found == False:
print( "The Searched Contact is not available in the Phone Book", searchname)

# first name
def input_firstname():
first = input( "Enter the First Name of the student: ")
remfname = first[1:]
firstchar = first[0]
return firstchar.upper() + remfname

# last name
def input_lastname():
last = input( "Enter the Last Name of the student: ")
remlname = last[1:]
firstchar = last[0]
return firstchar.upper() + remlname

# storing the new contact details


def newcontact():
firstname = input_firstname()
lastname = input_lastname()
D_No = input( "Enter the D Number: ")
Attendence_Status = input( "Enter the Attendence Status of the student: ")
Student_Record = ("[" + firstname + " " + lastname + ", " + D_No + ", " + Attendence_Status +
"]\n")
myfile = open(filename, "a")
myfile.write(Student_Record)
print( "The following Contact Details:\n " + Student_Record + "\nhas been stored successfully!")

main_menu()
THE FLOWCHART FOR ATTENDENCE RECORD SYSTEM:
THE .py FILE FOR ATTENDENCE RECORD SYSTEM:

THE .py FILE FOR ATTENDENCE RECORD SYSTEM:

You might also like