I have posted this question before. But the answer is the exact same one as the other's people question solution So , I

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

I have posted this question before. But the answer is the exact same one as the other's people question solution So , I

Post by answerhappygod »

I have posted this question before. But the answer isthe exact same one as the other's people questionsolutionSo , I need another answer other than the answered similarquestion in answers Im trying to create a student attendance list in python programme.(use my code to finish what I wanted)
My function consists 5
1) Generate code for student to mark their attendance
2) Manually add student id, name, attendance into the textfile
3) search the specific student id and name to show theirattendance status
4) Percentage of total student present
5) sorting the student name list in the text file intoalphabetical order
So here my questions
1) How to manually add a new student id, name , presentinto the text file?2) How to search a specific student id, name to see if the studentpresent or not
3) How to sort the student list into alphabeticalorder?
this is the code i've done so far
def records():while True:print("\n ")print("Enter 1 to 5 for following options: ")print("1 -> Start attendance marking")print("2 -> ")print("3 -> Attendance Percentage")print("4 -> History")print("5 -> Exit ")try:a =int(input("\nEnter option: "))except ValueError:print("Invalid input, please enter a number!")records()if(a==1):main()if(a==3):attendance_percentage()if(a==4):print()display_attendance()if(a==5):print('Exiting the program......')breakdef main():with open("studentlist.txt") as file:print()print()print("Welcome to CAMS ")print()askinput()
for line in file:process_student(line)
attendance_marking()
all_data = []attendance_list = []attendance_boolean_list = []
def process_student(lines):
# Assigning list to variables haha
parts = lines.split()id = parts[0]name = parts[1]attendance_status = str(parts[2])
# Rebuilding the main list because .readline() cannot be used
textline = id + " " + name + " " + attendance_status + "\n"
global all_dataall_data.append(textline)
# List for attendance, sussy
global attendance_listattendance_list.append(attendance_status)
global attendance_boolean_listattendance_boolean_list.append(bool(attendance_status))def askinput():global ask_idask_id = int(input("Enter your student id : "))
global userinputprint('The attendance code is: '+ ran)userinput = str(input("\nEnter attendance code : "))
def display_attendance():for i in range (0, len(all_data)):id_name = str(all_data)[:-7]result = attendance_listprint(id_name,result)
import stringimport randomS = 6ran = ''.join(random.choices(string.ascii_uppercase +string.digits, k = S))attendance_code = str(ran)#attendance marking functionsdef attendance_marking():if str(userinput)==str(attendance_code):attendance_list[ask_id-1]=str("True")attendance_boolean_list[ask_id-1]=bool(True)else:print("Invalid code ")
def attendance_percentage():global totaltotal=0with open(r"C:\Users\edgar\Desktop\Programming\studentlist.txt",'r') as fp:x = len(fp.readlines())for i in range (0, len(all_data)):result = attendance_listif (len(result)==4):global percentagetotal+=1total_percentage= int((total/x)*100)print("\nTotal student present: ", total)print("Student attendance percentage : ", total_percentage,"%")

I Have Posted This Question Before But The Answer Is The Exact Same One As The Other S People Question Solution So I 1
I Have Posted This Question Before But The Answer Is The Exact Same One As The Other S People Question Solution So I 1 (33.71 KiB) Viewed 31 times
def records(): while True: print("\n ") print("Enter 1 to 5 for following options: ") print("1 -> Start attendance marking") print("2 -> ") print("3 -> Attendance Percentage") print("4 -> History") print("5 -> Exit ") try: a = int(input("\nEnter option: ")) except ValueError: print("Invalid input, please enter a number!") records () if(a==1): main() if(a==3): def main(): attendance_percentage() if(a==4): print() display_attendance () print('Exiting the program...………') if(A==5): break with open("studentlist.txt") as file: print() print() print("Welcome to CAMS ") print() askinput() for line in file: process_student (line) attendance_marking() all_data = [] attendance_list = [] attendance_boolean_list = []
def process_student (lines): # Assigning list to variables haha parts = lines.split() id = parts[0] name = parts [1] attendance_status = str(parts [2]) # Rebuilding the main list because textline= id + " " + name + " " + global all data all_data.append(textline) # List for attendance, sussy global attendance_list global attendance_boolean_list attendance_list.append(attendance_status) def askinput(): .readline() cannot be used attendance_boolean_list.append(bool(attendance_status)) attendance_status + "\n" global ask_id ask_id = int(input("Enter your student id : ")) def display_attendance(): global userinput print('The attendance code is: '+ ran) userinput = str(input("\nEnter attendance code: ")) for i in range (0, len(all_data)): id_name = str(all_data)[:-7] result = attendance_list print(id_name, result)
import string import random S = 6 ran = ''.join(random.choices(string.ascii_uppercase + string.digits, k = S)) attendance_code = str(ran) #attendance marking functions def attendance_marking(): if str(userinput)==str(attendance_code): attendance_list[ask_id-1]=str("True") attendance_boolean_list[ask_id-1]=bool(true) print("Invalid code ") def attendance_percentage (): global total total=0 with open("C:\Users\edgar\Desktop\Programming\studentlist.txt", 'r') as fp: else: x = len(fp.readlines()) for i in range (0, len(all_data)): result = attendance_list if (len(result)==4): global percentage total+=1 total_percentage= int((total/x)*100) print("\nTotal student present: ", total) print("Student attendance percentage : ", total_percentage, "%") records ()
1 Jonathan False 2 Lucas False 3 Christiane False 4 Jackson False 5 Carson False 6 Siew False 7 7 Cassandra False 8 8 Gareth False 9 9 Joel False 10 10 James False 1 HNM &non ∞ o 2 3 4 5 6
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply