class 12 computer science practical paper with solution 2024

class 12 computer science practical paper with solution 2024

AISSCE Practical Examination 2024

COMPUTER SCIENCE (083)

Time : 3 Hours                                                                                      M.M.  30

 

Q1.                                                                                                                                                                                                                  8

(i) Write a user defined function countvowels() in Python to count and display the number of vowels in a text file “data.txt”.
(ii) A binary file “employee.dat” has structure [Empid,  EName, Designation ].
a) Write a user defined function Create() to input data for a record and add it to employee.dat .
b) Write a user defined function Display() in Python to display those records from “employee.dat” where Empid is more than 101.

Q2.                                                                                                                                                                                                               4

The code given below inserts the following record in the table  Student:

RollNo – integer
Name – string
Clas – integer
Marks – integer
Note the following to establish connectivity between Python and MYSQL:

  • Username is root
  • Password is root
  • The table exists in a MYSQL database named school.
  • The details (RollNo, Name, Clas and Marks) are to be accepted from the

Write the following missing statements to complete the code:   2+3

Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table Student.
Statement 3- to add the record permanently in the database
Statement 4- to close the database connection.

import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host=”localhost”,user=”root”, password=”root”, database=”school”)
mycursor=                              #Statement 1   
RollNo=int(input(“Enter Roll Number :: “))
Name=input(“Enter name :: “)
Cas=int(input(“Enter class :: “))
Marks=int(input(“Enter Marks :: “))
querry=”insert into student values({},'{}’,{},{})”.format(rno,name,clas,marks)
____________________________  #Statement 2
_____________________________ # Statement 3
print(“Data Added successfully”)

____________________________  #Statement 4

                                                                                                                           

Q3.Practical File                                                                       7

Q4.Project File                                                                          8

Q5.Viva-Voce                                                                             3

 

Solution:

 Q1

i.

def countvowels():
    f=open(“data.txt”,”r”)
    count=0
    data=f.read()
    for d in data:
           if d in [‘a’,’e’,’i’,’o’,’u’]:
                  count+=1
     f.close()

   print(‘Number of vowels=’,count)

ii

(a) import pickle

 def Create():
    f=open(“employee.dat”,”ab”)
    Empid=int(input(“Enter Empid: “))
    EName=input(“Enter Name of employee:”)
    Designation = input(“Enter Designation: “)
    record=[Empid, EName,Designation]
    pickle.dump(record, f)
    f.close()

 (b)

def Display():
    f=open(“employee.dat”,”rb”)
    try:
        while True:
            record=pickle.load(f)
             if record[0]>101:
                  print(record)
    except:
        f.close()
 

 Q2.

#Statement 1 – con1.cursor()
#Statement 2 – mycursor.execute(querry)
#Statement 3 – con1.commit()
#Statement 4 – con1.close()


Class xii computer science Practical paper – 2

Class xii computer science project file

Class 12 Computer Science Practical File

Click here for Quiz on Python Basics



Popular Books of Computer Science



Spread the love
Lesson tags: class 12 computer science practical paper, computer science practical paper class 12
Back to: CBSE class 12 Computer Science notes
Spread the love