Python project class 12 cbse

YOU WOULD BE FAMILIAR WITH THESE ATTENDANCE REGISTERS WHICH ARE CARRIED BY SCHOOL TEACHERS. Although these are trouble for those who bunk classes but still.......
Practically and honestly speaking, we make school project to please teacher and gain marks. Nothing would be better than gifting a digital attendance register !! It will save trees and time of teachers.
So I had idea to make digital attendance register with python.
Let's get started......... step1: open command promt as administrator
step 2: type "pip install pyttsx3.drivers.sapi5" and hit enter. Wait for it to complete.
pyttsx3 is a module to convert text to speech and is used here to make the program interactive.
step3: open idle where you are going to write script of program. step4: copy and paste the following code:
#------------modules to be used in file name---------------------
import pyttsx3
import datetime as dt

#----------------for converting text to speech----------------------------
def speak(speech):        #Making program interactive 
    <bol.say(speech)
    bol.runAndWait()
    
#------------------__main__------------------------------------
bol=pyttsx3.init()
totala=0
totalp=0
totall=0
speak("please enter the following details")
name=input("Enter name (exclude file extension) of file which has names of students: ") #To make it more productive
names=name+'.txt'    #in order to make it Easy-to-use
with open(names, 'r') as f:
    st = [line.strip() for line in f] #to remove newline character

a=str(dt.datetime.now())   #date will be inserted to name of file
date = a[0:11]
sayy="Enter class and section: "

speak(sayy) 
clss=input(sayy) 
#---------------------initial presentation--------------
say1=('''Mark your attendance
                 type p for present
                 a for absent
                 l for leave
                 !!!!input is case sensitive!!!!!''')
print(say1)
speak(say1)
                  
#----------------main program------------------------------

for i in st:   #to get name of every student using loop
    with open(f"{date}_{clss}-Attendance.csv","a+") as file:  #can be opened in notepad and excel

       attend = input(f"{i}: ")
        if attend=="p":
            totalp+=1
            file.write(f"{i},Present\n")
            
        elif attend=="a":
            totala+=1
           file.write(f"{i},Absent\n")
            
        elif attend=='l':
            totall+=1
            file.write(f"{i},Leave\n")
            
       else:
            say2="Error 404: focus on work not found" #just for fun
           print(say2)
            speak(say2)
            with open(f"{date}_{clss}-Attendance.csv","a+") as file:
      
                attend = input(f"{i}: ")
                if attend=="p":
                    totalp+=1
                    file.write(f"{i},Present\n")
                    
               elif attend=="a":
                    totala+=1
                   file.write(f"{i},Absent\n")
                    
               elif attend=='l':
                   totall+=1
                   file.write(f"{i},Leave\n")
                   
                else:                  
                    say3=('''Error 404: focus on work not found    
                          Now I am not going to help you
                           do your work manually
                           this is your punishment
                           hahaahaha''')
                    print(say3)
                    speak(say3)
       
   
print("total students present= ",totalp)
print("total students absent are= ",totala)
print("total students  leave are= ",totall)

#-------------total students----------------------------
with open(f"{date}_{clss}-totalAttendance.txt","a") as file:    
    file.write(f"total students present= {totalp}\n")
    file.write(f"total students absent= {totala}\n")  
    file.write(f"total students on leave= {totall}\n")
    file.write('''
-------------------------------end---------------------------            
                \n''')
#--------------to tackle multiple entries, if any.....   
with open(f"{date}_{clss}-Attendance.csv","a+") as file:   #To distinguish betweeen multiple entries
   file.write('''-------------------------------end---------------------------            
                    \n''')    



  speak("Your work is saved successfully") #Formality
step4: make txt file and store names of student in same directory where this program is saved. Note: You need to make a file which holds name of students. Make a .txt file and store name there.
Press enter after each name as each line will be considered as one name. Do not use comma to separate two names as this will not work. In simple words, each line must hold single name.
step5: now run the program. It will ask for name of txt file which has names of student saved. You do not need to specify extension.....just type name. step5: follow the instructions of program Now the program will make 2 files. One file will store total attendance and other will have each student's name and attendance. Other file will be csv so you can easily run it in excel and notepad together. enjoy !!!! for more info....comment on my youtube channel:https://www.youtube.com/channel/UC5H8rzii0G_lPjgtwSW_9WA

Comments

  1. Best Python project I have read. Information technology is an important subject in CBSE but there aren't many CBSE Projects for information technology like python/java etc.

    ReplyDelete

Post a Comment