Write a program to read the content of a text file and display
Program–20 :     the total number of consonants, uppercase, vowels and lower
                 case characters.
  #Program to read content of file and display total number of vowels,
  #consonants, lowercase and uppercase characters
  f = open("e:\\files\\file1.txt")
  v=0
  c=0
  u=0
  l=0
  o=0
  data = f.read()
  vowels=['a','e','i','o','u']
  for ch in data:
     if ch.isalpha():
         if ch.lower() in vowels:
             v+=1
         else:
             c+=1
         if ch.isupper():
             u+=1
         elif ch.islower():
             l+=1
         elif ch!=' ' and ch!='\n':
             o+=1
  print("Total Vowels in file :",v)
  print("Total Consonants in file n :",c)
  print("Total Capital letters in file :",u)
  print("Total Small letters in file :",l)
  print("Total Other than letters :",o)
  f.close()
   NOTE : if the original content of file is:
   India is my country
   I love python
   Python learning is fun
   123@
   OUTPUT:
   Total Vowels in file : 16
   Total Consonants in file n : 30
   Total Capital letters in file : 2
   Total Small letters in file : 44
   Total Other than letters : 4
                Write a program to read and display file content line by line
Program–21 :
                with each word separated by #.
  #Program to read content of file line by line &
  # display each word separated by '#'
  f = open("e:\\files\\file1.txt")
  for line in f:
     words = line.split()
     for w in words:
        print(w+'#',end='')
     print()
  f.close()
   NOTE : if the original content of file is:
   India is my country
   I love python
   Python learning is fun
   OUTPUT:
   India#is#my#country#
   I#love#python#
   Python#learning#is#fun#
               Write a program to read the content of file line by line and
Program–22 :   write it to another file except for the lines that contains ‘a'
               letter in it.
  #Program to read line from file and write it to another line
  #Except for those line which contains letter 'a'
  f1 = open("e:\\files\\file2.txt")
  f2 = open("e:\\files\\file2copy.txt","w")
  for line in f1:
     if 'a' not in line:
         f2.write(line)
  print(“## File Copied Successfully! ##”)
  f1.close()
  f2.close()
   NOTE: If Content of file2.txt
   a quick brown fox
   one two three four
   five six seven
   India is my country
   eight nine ten
   bye!
   OUTPUT:
   ## File Copied Successfully! ##
   NOTE: After copy content of file2copy.txt
   one two three four
   five six seven
   eight nine ten
   bye!
               Write a program to display the word with maximum length
Program–23 :
               from a text file.
  f=open("g:\\files\\story.txt","r")
  lword=''
  for t in f.readlines():
     for r in t.split():
         if len(r)>len(lword):
             lword=r
  print("maximum length word is ",lword)
   NOTE: If Content of story.txt
   A Boy is playing there
   Deep in to the river, Dive in to the sea
   Here come the Way
   An Aeroplane is in the sky
   OUTPUT:
   maximum length word is Aeroplane
                Write a menu-program to do the following:
                1. To count occurrences of words ‘to’ and ‘the’
Program–24 :    2. To append the contents of one file to another.
                3. To read a file line by line and display every line along with
                line no. in sentence case.
  #function to count the occurrences of word ‘to’ and ‘the’
  def count():
    f=open('e:\\files\\poem.txt','r')
    tocnt=0
    thecnt=0
    data=f.read()
    listwords=data.split()
    for word in listwords:
       if word.lower()=="to":
          tocnt+=1
       elif word.lower=="the":
          thecnt+=1
    print("No. of words 'to' and 'the' in file",tocnt+thecnt)
    f.close()
  #Alternative way
  def count():
    f=open('e:\\files\\poem.txt','r')
    count=0
    lines=f.readlines()
    for line in lines:
       words=line.split()
       print(words)
       tocnt=words.count("to")
       thecnt=words.count("the")
       count=count+tocnt+thecnt
    print("No. of words 'to' and 'the' in file",count)
    f.close()
  #function to append the contents of one file to another
  def append():
    infile=input("Enter the filename to read from:")
    outfile=input("Enter the filename to append into:")
    outf=open('e:\\files\\'+outfile,'a')
    with open('e:\\files\\'+infile,'r') as f:
       content=f.read()
       outf.write('\n')
       outf.write(content)
    f.close()
    outf.close()
    print("File processed successfully")
#function to display every line of file in sentence case along with line no.
def sentencecase():
  f = open("e:\\files\\poem.txt","r")
  lcnt=0
  for line in f:
      line = line[0].upper()+line[1:].lower()
      #line=line.capitalize()
      lcnt = lcnt+1
      print(lcnt,line)
  f.close()
choice=0
while choice!=4:
  print("\t\t1. To count words 'to' and 'the'")
  print("\t\t2. To append")
  print("\t\t3. To display lines in sentence case")
  print("\t\t4. To exit")
  choice=int(input("Enter your Choice [ 1 - 4 ]: "))
  if choice==1:
      count()
  elif choice==2:
      append()
  elif choice==3:
      sentencecase()
  elif choice==4:
      break
 NOTE:
 If Content of poem.txt is
 deep in to the river
 here come the way
 If Content of newpoem.txt is
 This is my poem.
 OUTPUT:
                    1. To count words 'to' and 'the'
                                    2. To append
                                    3. To display lines in sentence case
                                    4. To exit
                    Enter your Choice [ 1 - 4 ]: 1
                    ['deep', 'in', 'to', 'the', 'river']
                    ['here', 'come', 'the', 'way']
                    No. of words 'to' and 'the' in file 3
                                    1. To count words 'to' and 'the'
                                    2. To append
                                    3. To display lines in sentence case
                                    4. To exit
                 Enter your Choice [ 1 - 4 ]: 2
                 Enter the filename to read from:poem.txt
                 Enter the filename to append into:newpoem.txt
                 File processed successfully
                              1. To count words 'to' and 'the'
                              2. To append
                              3. To display lines in sentence case
                              4. To exit
                 Enter your Choice [ 1 - 4 ]: 3
                 1 Deep in to the river
                 2 Here come the way
                              1. To   count words 'to' and 'the'
                              2. To   append
                              3. To   display lines in sentence case
                              4. To   exit
     Enter your Choice [ 1 - 4 ]: 4
After program execution, Content of newpoem.txt is
This is my poem.
deep in to the river
here come the way
                 Write a program to write a dictionary object containing roman
                 numbers and their equivalents onto a binary file decroman.bin.
Program–25 :     The program should input a decimal number and use the
                 convertor dictionary object stored in the file to calculate and
                 display it’s roman equivalent.
  #Program demonstrating use of pickle module
  #to dump and load dictionary object in/from a binary file
  import pickle
  numerals={1000:'M',900:'CM',500:'D',400:'CD',100:'C',90:'XC',50:'L',40:'XL',
  10:'X',9:'IX',5:'V',4:'IV',1:'I'}
  f=open("e:\\files\\decroman.bin","wb")
  pickle.dump(numerals,f)
  f.close()
  f=open("e:\\files\\decroman.bin","rb")
  num=pickle.load(f)
  print("Dictionary Decimal-Roman Convertor:",num)
  f.close()
  dec_num=int(input("Enter a decimal number:"))
  roman=""
  val=list(num.keys())
  sym=list(num.values())
  temp=dec_num
  while temp!=0:
     i=0
     while(temp<val[i]):
        i+=1
     quot=temp//val[i]
     roman=roman+sym[i]*quot
     temp=temp-quot*val[i]
  print("Corresponding Roman No:",roman)
   OUTPUT:
   Dictionary Decimal-Roman Convertor: {1000: 'M', 900: 'CM', 500: 'D', 400:
   'CD', 100: 'C', 90: 'XC', 50: 'L', 40: 'XL', 10: 'X', 9: 'IX', 5: 'V', 4: 'IV', 1: 'I'}
   Enter a decimal number:45
   Corresponding Roman No: XLV
               Write a program to create a binary file emp.dat storing
               employee records in the form of empno, name, salary,
               allowances, deductions. The program should input the name of
Program–26 :
               employee and search it in binary file emp.dat and display the
               netsalary of employee.
               [Note: netsalary=salary+allowances-deductions]
  #program to create a binary file emp.dat storing employee records
  #and search an employee record in file.
  import pickle
  f=open('e:\\files\\emp.dat','wb')
  recno=1
  emp=[]
  while True:
     eno=int(input("Enter employee no:"))
     name=input("Enter employee name:")
     salary=int(input("Enter employee salary:"))
     allow=int(input("Enter employee allowances:"))
     ded=int(input("Enter employee deductions:"))
     rec=[eno,name,salary,allow,ded]
     emp.append(rec)
     ans=input("Do you want to enter more records:")
     if ans.upper()=='N':
            break
     recno+=1
  pickle.dump(emp,f)
  print("Employee records stored:",recno)
  print("Size of binary file(in bytes)",f.tell())
  f.close()
  ename=input("Enter employee name to search:")
  try:
      with open("e:\\files\\emp.dat","rb") as f:
         while True:
             emp=pickle.load(f)
  except EOFError:
         pass
  found=False
  for rec in emp:
         if rec[1]==ename:
                netsalary=rec[2]+rec[3]-rec[4]
                print("Employee Name:",rec[1],"-> NetSalary:",netsalary)
                found=True
                break
  if found==False:
             print("Employee record doesnot exists!!!")
OUTPUT:
Enter employee no:101
Enter employee name:sheena
Enter employee salary:24000
Enter employee allowances:4000
Enter employee deductions:3000
Do you want to enter more records:y
Enter employee no:102
Enter employee name:rishi
Enter employee salary:35000
Enter employee allowances:5000
Enter employee deductions:2500
Do you want to enter more records:n
Employee records stored: 2
Size of binary file(in bytes) 63
Enter employee name to search:rishi
Employee Name: rishi -> NetSalary: 37500
                  Write a menu-driven program with function to create a binary
                  file 'student.dat' storing student records in the following
Program–27 :      format: [RollNo, Name, Marks]. Write an interactive program
                  with function to perform append, search, display, update and
                  delete operations.
  #menu-driven program to handle binary file student.dat
  import pickle
  import os
  #To create binary file to add student records
  def create():
    f=open('e:\\files\\student.dat','wb')
    ans='y'
    while ans.lower()=='y':
        roll = int(input("Enter Roll Number :"))
        name = input("Enter Name :")
        marks = int(input("Enter Marks :"))
        rec=[roll,name,marks]
        pickle.dump(rec,f)
        ans=input("Add More ?(y/n)")
    f.close()
  #To append records at the end of binary file
  def append():
    f=open('e:\\files\\student.dat','ab')
    roll = int(input("Enter Roll Number :"))
    name = input("Enter Name :")
    marks = int(input("Enter Marks :"))
    rec=[roll,name,marks]
    pickle.dump(rec,f)
    f.close()
  #To display all student records
  def display():
    if os.path.isfile("e:\\files\\student.dat"):
        f=open('e:\\files\\student.dat','rb')
        print("## All Student Records ##")
        print("RollNo\tName\t\tMarks")
        print("--------------------------------------------------------")
        try:
           while True:
              rec = pickle.load(f)
              print(rec[0],"\t",rec[1],"\t\t",rec[2])
     except EOFError:
        pass
     f.close()
  else:
     print("File not found!!!")
#To search student record based on input rollno
def search():
  if os.path.isfile("e:\\files\\student.dat"):
      f=open('e:\\files\\student.dat','rb')
      r = int(input("Enter Roll number to search :"))
      try:
          found=False
          while True:
             rec = pickle.load(f)
             if rec[0]==r:
                 print("## Name is :",rec[1], " ##")
                 print("## Marks is :",rec[2], " ##")
                 found=True
                 break
      except EOFError:
          pass
      if found==False:
      #if not found:
          print("####Sorry! Roll number not found ####")
      f.close()
  else:
      print("File not found!!!")
#To update marks of particular rollno
def update():
  if os.path.isfile("e:\\files\\student.dat"):
      f=open('e:\\files\\student.dat','rb')
      r = int(input("Enter Roll number to update :"))
      student=[]
      try:
         found=False
         while True:
            rec = pickle.load(f)
            if rec[0]==r:
                print("## Name is :",rec[1], " ##")
                print("## Current Marks is :",rec[2]," ##")
                m = int(input("Enter new marks :"))
                rec[2]=m
                print("## Record Updated ##")
               found=True
            student.append(rec)
     except EOFError:
         pass
     f.close()
     if found==False:
            print("####Sorry! Roll number not found ####")
     else:
         f=open('e:\\files\\student.dat','wb')
         for rec in student:
            pickle.dump(rec,f)
         f.close()
  else:
     print("File not found!!!")
#To delete record particular rollno
def delete():
  if os.path.isfile("e:\\files\\student.dat"):
      f=open('e:\\files\\student.dat','rb')
      r = int(input("Enter Roll number to delete :"))
      student=[]
      try:
          found=False
          while True:
             rec = pickle.load(f)
             if rec[0]==r:
                 print("## Record Deleted ##")
                 found=True
             else:
                 student.append(rec)
      except EOFError:
          pass
      f.close()
      if found==False:
             print("####Sorry! Roll number not found ####")
      else:
          f=open('e:\\files\\student.dat','wb')
          for rec in student:
             pickle.dump(rec,f)
          f.close()
  else:
      print("File not found!!!")
while True:
#while choice!=7:
 print("\t\t1. To create binary file")
 print("\t\t2. To append record")
 print("\t\t3. To display all records")
 print("\t\t4. To search record")
 print("\t\t5. To update record")
 print("\t\t6. To delete record")
 print("\t\t7. To exit")
 choice=int(input("Enter your Choice [ 1 - 7 ]: "))
 if choice==1:
     create()
 elif choice==2:
     append()
 elif choice==3:
     display()
 elif choice==4:
     search()
 elif choice==5:
     update()
 elif choice==6:
     delete()
 elif choice==7:
     break
OUTPUT:
            1. To create binary file
            2. To append record
            3. To display all records
            4. To search record
            5. To update record
            6. To delete record
            7. To exit
Enter your Choice [ 1 - 7 ]: 1
Enter Roll Number :1
Enter Name :lavina
Enter Marks :23
Add More ?(y/n)y
Enter Roll Number :2
Enter Name :rohit
Enter Marks :56
Add More ?(y/n)n
            1. To create binary file
            2. To append record
            3. To display all records
            4. To search record
            5. To update record
            6. To delete record
            7. To exit
 Enter your Choice [ 1 - 7 ]: 2
Enter Roll Number :3
Enter Name :shobha
Enter Marks :54
               1. To create binary file
               2. To append record
               3. To display all records
               4. To search record
               5. To update record
               6. To delete record
               7. To exit
Enter your Choice [ 1 - 7 ]: 3
## All Student Records ##
RollNo      Name              Marks
--------------------------------------------------------
1          lavina              23
2          rohit               56
3          shobha              54
               1. To create binary file
               2. To append record
               3. To display all records
               4. To search record
               5. To update record
               6. To delete record
               7. To exit
Enter your Choice [ 1 - 7 ]: 4
Enter Roll number to search :5
####Sorry! Roll number not found ####
               1. To create binary file
               2. To append record
               3. To display all records
               4. To search record
               5. To update record
               6. To delete record
               7. To exit
Enter your Choice [ 1 - 7 ]: 5
Enter Roll number to update :2
## Name is : rohit ##
## Current Marks is : 56 ##
Enter new marks :100
## Record Updated ##
               1. To create binary file
               2. To append record
               3. To display all records
               4. To search record
               5. To update record
               6. To delete record
               7. To exit
Enter your Choice [ 1 - 7 ]: 4
Enter Roll number to search :2
## Name is : rohit ##
## Marks is : 100 ##
            1. To create binary file
            2. To append record
            3. To display all records
            4. To search record
            5. To update record
            6. To delete record
            7. To exit
Enter your Choice [ 1 - 7 ]: 6
Enter Roll number to delete :3
## Record Deleted ##
            1. To create binary file
            2. To append record
            3. To display all records
            4. To search record
            5. To update record
            6. To delete record
            7. To exit
Enter your Choice [ 1 - 7 ]: 7
                Write a program to create a CSV file delimited by ‘#’ and store
                employee records in the form of empno, name, salary. The
Program–28 :    program should input empno and search and display the name
                & salary of corresponding employee. Also display appropriate
                message, if record is not found.
  import csv
  with open('e:\\files\\employee.csv',mode='w') as csvfile:
    mywriter = csv.writer(csvfile,delimiter='#')
    ans='y'
    emprec=[]
    while ans.lower()=='y':
       eno=int(input("Enter Employee Number "))
       name=input("Enter Employee Name ")
       salary=int(input("Enter Employee Salary :"))
       emprec.append([eno,name,salary])
       ans=input("Add More ?")
    print("## Data Saved... ##")
    mywriter.writerows(emprec)
  with open('e:\\files\\employee.csv',mode='r') as csvfile:
    myreader = csv.reader(csvfile,delimiter='#')
    ans='y'
    while ans=='y':
       found=False
       e = int(input("Enter Employee Number to search :"))
       for row in myreader:
          if len(row)!=0:
              if int(row[0])==e:
                  print("============================")
                  print("NAME :",row[1])
                  print("SALARY :",row[2])
                  found=True
                  break
       if not found:
          print("==========================")
          print(" EMPNO NOT FOUND")
          print("==========================")
       ans = input("Search More ? (Y)")
   OUTPUT:
   Enter Employee   Number 1
   Enter Employee   Name Lavina
   Enter Employee   Salary :20000
   Add More ?y
   Enter Employee   Number 2
   Enter Employee   Name Krish
Enter Employee Salary :40000
Add More ?y
Enter Employee Number 3
Enter Employee Name Kishore
Enter Employee Salary :35000
Add More ?n
## Data Saved... ##
Enter Employee Number to search :2
============================
NAME : Krish
SALARY : 40000
Search More ? (Y)y
Enter Employee Number to search :4
==========================
EMPNO NOT FOUND
==========================
Search More ? (Y)n
Content of file employee.csv after the execution of code
1#Lavina#20000
2#Krish#40000
3#Kishore#35000
                 Write a program to create a CSV file containing player details
                 (playername and ranking) in the form dictionary and read the
Program–29 :
                 CSV file as a dictionary to display the ranking of a particular
                 player.
  #Program to read a given CSV file as a dictionary.
  import csv
  with open('e:\\files\\players.csv', 'w', newline='') as file:
    fieldnames = ['playername', 'ranking']
    writer = csv.DictWriter(file, fieldnames=fieldnames)
    writer.writeheader()
    ans='y'
    pdict={}
    while ans.lower()=='y':
       pname=input("Enter Player Name: ")
       rank=int(input("Enter Ranking: "))
       pdict[fieldnames[0]]=pname
       pdict[fieldnames[1]]=rank
       writer.writerow(pdict)
       print("## Data Saved... ##")
       ans=input("Add More ?")
  name=input("Enter Player Name to Search:")
  found=False
  with open("e:\\files\\players.csv", 'r') as file:
     reader = csv.DictReader(file)
     for row in reader:
         pdict=dict(row)
         if name==pdict[fieldnames[0]]:
            print(pdict)
            print("Player's Ranking:",pdict[fieldnames[1]])
            found=True
            break
     if not found:
         print("No such player record exists!!!")
   OUTPUT:
   Enter Player Name: Sachin
   Enter Ranking: 5
   ## Data Saved... ##
   Add More ?y
   Enter Player Name: Virat
   Enter Ranking: 1
   ## Data Saved... ##
   Add More ?y
Enter Player Name: Dhoni
Enter Ranking: 10
## Data Saved... ##
Add More ?n
Enter Player Name to Search:Dhoni
{'playername': 'Dhoni', 'ranking': '10'}
Player's Ranking: 10
                Write a menu-driven program to create a CSV file (users.csv)
                containing user records in the form of UserID, Password and
Program–30 :
                UserType and perform search, update, delete and append
                operations on it.
  #Menu-driven program to handle csv file containing user records
  import csv
  import os
  #To create csv file
  def create():
    f=open("e:\\files\\users.csv","w",newline='')
    csvwriter = csv.writer(f)
    ans='y'
    urec=[]
    header=["UserID","Password","UserType"]
    csvwriter.writerow(header)
    while ans.lower()=='y':
        userid=input("Enter UserID: ")
        pwd=input("Enter password: ")
        usertype=input("Enter usertype->'a'-admin,'t'-teacher,'s'-student):")
        urec=[userid,pwd,usertype]
        csvwriter.writerow(urec)
        ans=input("Add More ?")
    print("##Records File Created... ##")
    f.close()
  #To search user records in csv file
  def search():
    if os.path.isfile("e:\\files\\users.csv"):
        f=open("e:\\files\\users.csv","r")
        csvreader=csv.reader(f)
        found=False
        uname=input("Enter username to search:")
        for row in csvreader:
            if csvreader.line_num==1:
                continue
            if row[0]==uname:
                print("Password:",row[1],"\tUserType:",row[2])
                found=True
                break
        if found==False:
            print("User record not found!!!")
        f.close()
    else:
        print("File not found...Create the file")
#To update user record in csv file
def update():
  if os.path.isfile("e:\\files\\users.csv"):
      f=open("e:\\files\\users.csv","r+",newline='')
      csvreader=csv.reader(f)
      found=False
      uname=input("Enter userid whose password is to be updated:")
      urec=[]
      for row in csvreader:
          if row[0]==uname:
              newpwd=input("Enter new password:")
              row[1]=newpwd
              found=True
          urec.append(row)
      if found==False:
          print("User record not found!!!")
      else:
          f.seek(0,0)
          csvwriter = csv.writer(f)
          csvwriter.writerows(urec)
          print("User record updated!!!")
      f.close()
  else:
      print("File not found!!!")
#To remove user record from csv file
def delete():
  if os.path.isfile("e:\\files\\users.csv"):
      f=open("e:\\files\\users.csv","r")
      csvreader=csv.reader(f)
      found=False
      uname=input("Enter userid to delete record: ")
      urec=list(csvreader)
     index=0
     for row in urec:
         if row[0]==uname:
             found=True
             break
         index=index+1
     f.close()
     if found==False:
         print("User record not found!!!")
     else:
         urec.pop(index)
         f=open("e:\\files\\users.csv","w",newline='')
         csvwriter = csv.writer(f)
         csvwriter.writerows(urec)
         print("User record deleted!!!")
        f.close()
  else:
     print("File not found!!!")
#To append user record into csv file
def append():
  if os.path.isfile(eg:\\files\\users.csv"):
      f=open("e:\\files\\users.csv","a",newline='')
      csvwriter = csv.writer(f)
      urec=[]
      userid=input("Enter UserID: ")
      pwd=input("Enter password: ")
      usertype=input("Enter usertype->'a'-admin,'t'-teacher,'s'-student):")
      urec=[userid,pwd,usertype]
      csvwriter.writerow(urec)
      print("##User Record Appended... ##")
      f.close()
  else:
      create()
#To count number of user records in csv file
def count():
  if os.path.isfile("e:\\files\\users.csv"):
      f=open("e:\\files\\users.csv","r")
      csvreader=csv.reader(f)
      c=0
      for row in csvreader:
         if csvreader.line_num==1: #skip the first header row
              continue
         c=c+1
      print("Total number of users:",c)
      f.close()
  else:
      print("File Not Found...Create the file")
#To display user records in csv file
def display():
  if os.path.isfile("e:\\files\\users.csv"):
      f=open("e:\\files\\users.csv","r")
      csvreader=csv.reader(f)
      print("1. As List")
      print("2. As Comma Separated Values")
      print("3. In Tabular Form")
      ch=int(input("Enter your choice:"))
     if ch==1:
        for row in csvreader:
           if csvreader.line_num==1:
               continue
           print(row)
     elif ch==2:
        for row in csvreader:
           if csvreader.line_num==1:
               continue
           print(','.join(row))
     else:
        for row in csvreader:
           if csvreader.line_num==1:
               print(row[0].upper(),'\t\t',row[1].upper(),'\t',row[2].upper())
               continue
           print(row[0],'\t\t',row[1],'\t\t',row[2])
     f.close()
  else:
     print("File not found...Create the file")
choice=0
student=[]
while choice!=9:
   print("\t1. To create csv file")
   print("\t2. To search")
   print("\t3. To update")
   print("\t4. To delete")
   print("\t5. To append")
   print("\t6. To count user records")
   print("\t7. To display records")
   print("\t9. To exit")
   choice=int(input("Enter your Choice [ 1 - 9 ]: "))
   if choice==1:
       create()
   elif choice==2:
       search()
   elif choice==3:
       update()
   elif choice==4:
       delete()
   elif choice==5:
       append()
   elif choice==6:
       count()
   elif choice==7:
       display()
   elif choice==9:
       break
 OUTPUT:
      1. To create csv file
      2. To search
      3. To update
      4. To delete
      5. To append
      6. To count user records
      7. To display records
      9. To exit
Enter your Choice [ 1 - 9 ]: 1
Enter UserID: ekta
Enter password: 1234
Enter usertype->'a'-admin,'t'-teacher,'s'-student):t
Add More ?n
##Records File Created... ##
      1. To create csv file
      2. To search
      3. To update
      4. To delete
      5. To append
      6. To count user records
      7. To display records
      9. To exit
Enter your Choice [ 1 - 9 ]: 6
Total number of users: 1
      1. To create csv file
      2. To search
      3. To update
      4. To delete
      5. To append
      6. To count user records
      7. To display records
      9. To exit
Enter your Choice [ 1 - 9 ]: 5
Enter UserID: amit
Enter password: ans123
Enter usertype->'a'-admin,'t'-teacher,'s'-student):t
##User Record Appended... ##
      1. To create csv file
      2. To search
      3. To update
      4. To delete
      5. To append
      6. To count user records
      7. To display records
      9. To exit
Enter your Choice [ 1 - 9 ]: 7
1. As List
2. As Comma Separated Values
3. In Tabular Form
Enter your choice:1
['ekta', '1234', 't']
['amit', 'ans123', 't']
        1. To create csv file
        2. To search
        3. To update
        4. To delete
        5. To append
        6. To count user records
        7. To display records
        9. To exit
Enter your Choice [ 1 - 9 ]: 2
Enter username to search:ekta
Password: 1234 UserType: t
        1. To create csv file
        2. To search
        3. To update
        4. To delete
        5. To append
        6. To count user records
        7. To display records
        9. To exit
Enter your Choice [ 1 - 9 ]: 3
Enter userid whose password is to be updated:ekta
Enter new password:123456
User record updated!!!
        1. To create csv file
        2. To search
        3. To update
        4. To delete
        5. To append
        6. To count user records
        7. To display records
        9. To exit
Enter your Choice [ 1 - 9 ]: 6
Total number of users: 2
        1. To create csv file
        2. To search
        3. To update
        4. To delete
        5. To append
        6. To count user records
        7. To display records
        9. To exit
Enter your Choice [ 1 - 9 ]: 7
1. As List
2. As Comma Separated Values
3. In Tabular Form
Enter your choice:3
USERID               PASSWORD         USERTYPE
ekta          123456            t
amit          ans123            t
       1. To create csv file
       2. To search
       3. To update
       4. To delete
       5. To append
       6. To count user records
       7. To display records
       9. To exit
Enter your Choice [ 1 - 9 ]: 4
Enter userid to delete record: ekta
User record deleted!!!
       1. To create csv file
       2. To search
       3. To update
       4. To delete
       5. To append
       6. To count user records
       7. To display records
       9. To exit
Enter your Choice [ 1 - 9 ]: 7
1. As List
2. As Comma Separated Values
3. In Tabular Form
Enter your choice:3
amit,ans123,t
       1. To create csv file
       2. To search
       3. To update
       4. To delete
       5. To append
       6. To count user records
       7. To display records
       9. To exit
Enter your Choice [ 1 - 9 ]: 9
Content of file users.csv after the execution of code
UserID,Password,UserType
amit,ans123,t