Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time #Allows us to use the time.sleep command
- import sys #Allows us to use sys commands (For us it is killing the program on line 50)
- import random
- def startup():
- print('\n'*200)
- username = input('Enter your username: ')
- password = input('Enter your password: ')
- if username == 'leeman' and password == 'password': #Checking the username and password match
- main_menu() #Finding Main Menu
- else:
- print('You have entered an incorrect username and password')
- time.sleep(2) #Wating 2 seconds
- startup()
- #--------------------------------------------------------------------------------------------------------------------------------------------------------------
- def main_menu():
- print('\n'*200) #Printing enough lines so that the startup menu can't be seen
- print('----- MAIN MENU -----') #
- print('Create New Student (C)') #
- print('Delete a Student (D)') # MAIN MENU GUI
- print('View Students (V)') #
- print('Exit Program (E)') #
- print('')
- decision = input('What is your decision: ')
- if decision == 'C':
- createstudent()
- elif decision == 'D':
- deletestudent()
- elif decision == 'V':
- viewstudent()
- elif decision == 'E':
- sys.exit()
- else:
- print('You have entered an invalid decision')
- time.sleep(2)
- print('Returning to main menu ')
- time.sleep(2)
- main_menu()
- #--------------------------------------------------------------------------------------------------------------------------------------------------------------
- def createstudent():
- print('\n'*200)
- fname=input("What is the student's forename: ")
- sname=input("What is the student's surname: ")
- dob=input("What is the student's birthday in the format 00/00/00: ")
- iid=random.randint(1,999)
- sid=str(iid)
- gender1=input("What is the student's gender out of Male(M),Female(F) and other(O)" )
- if gender1 == 'M':
- gender2 = ('male')
- elif gender1 == 'F':
- gender2 == female
- elif gender1 == 'O':
- gender2 = input('What gender would the student like to be refered as: ')
- else:
- print('You have entered an invalid gender')
- createstudent()
- shome=input("What is the student's home phone number: ")
- saddress=input("What is the student's home address: ")
- sform=input("What is the student's form group: ")
- with open('students.txt','a') as student:
- student.write('\nID'+sid) #
- student.write('\n'+fname) #
- student.write('\n'+sname) #
- student.write('\n'+dob) #
- student.write('\n'+gender2) # Writing new students to file
- student.write('\n'+shome) #
- student.write('\n'+saddress) #
- student.write('\n'+sform) #
- student.write('\n'*2) #
- crdecision=input('Do you want to add another student: ')
- if crdecision == 'Yes':
- createstudent()
- else:
- print('Returning to main menu ')
- time.sleep(2)
- main_menu()
- #----------------------------------------------------------------------------------------------------------------------------------------------------------------
- def deletestudent():
- pass
- #----------------------------------------------------------------------------------------------------------------------------------------------------------------
- def viewstudent():
- print('\n'*200)
- IDinput=input("Please enter in the student's ID you want to display ")
- with open('students.txt','r') as student:
- data = student.read().splitlines() #Making is so it doesn't make new line between each line of information
- for i in range(len(data)):
- if data[i][:2]=='ID':
- ID = data[i][2:]
- if IDinput == ID:
- print('\n'*2)
- print("ID: "+ID)
- fname=data[i+1]
- sname=data[i+2]
- dob=data[i+3]
- gender=data[i+4]
- shome=data[i+5]
- saddress=data[i+6]
- sform=data[i+7]
- print("Forename: "+fname)
- print("Surname: "+sname)
- print("Date of Birth: "+dob)
- print("Gender: "+gender)
- print("Phone Number: "+shome)
- print("Home Address: "+saddress)
- print("Form Group: "+sform)
- print('\n'*2)
- vstudent=input('Do you want to display another student when you are done ')
- if vstudent == 'Yes':
- viewstudent()
- elif vstudent == 'yes':
- viewstudent()
- else:
- time.sleep(1)
- print('Returning to main menu')
- print('\n'*2)
- time.sleep(3)
- main_menu()
- else:
- print('You have entered an invalid ID ')
- time.sleep(1)
- print('Returning to view student menu ')
- time.sleep(2)
- viewstudent()
- startup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement