Anjeev Singh Academy

CBSE XII Computer Science 083 Practical Question Paper Set 1 – Download

AISSCE XII Computer Science 083 – Practical Question Paper Set #1 – Download Word File

All India Senior Secondary Certificate Examination
XII Computer Science 083 – Practical Question Paper Set #1


Answer Key of Set 1 Practical Examination Question Paper

ANSWER KEY – SET 1

Q1. LAB TEST                                                                                            [8+4=12]

A. 1) Write a Python Program read a text file line by line and display each word separated by a #.   (4)

Answer:

            # Creating a text file

fout = open(“story.txt”, ‘w’)

fout.write(“Hello How are You\n”)

fout.write(“I am fine\n”)

fout.write(“Thankyou\n”)

fout.close()

# Reading a text file, the Actual answer which you suppose to write

fin = open(“story.txt”, “r”)

line = ‘ ‘

while line:

    line = fin.readline()

    for word in line.split():

        print(word+’#’, end=’ ‘)

    print()

fin.close()

Output:

Hello# How# are# You#
I# am# fine#
Thankyou#

OR

     Define a function printPattern(line), which can print the given pattern.                                    (4)

                If value of line is 3, then function can print a pattern like

#

##

###

Answer:

def printPattern(line):

    for n in range(1, line+1):

        print(“#” * n)

line = int(input(“Enter number of line : “))

printPattern(line)

Output:

Enter number of line: 4

#

##

###

####

   2) Create a python program to create a stack of student’s marks.                                                         (4)

  • Write function PUSH to add marks in to the stack and
  • Write function POP to remove the marks from stack and display the same.

Answer:

marks = []

def PUSH(m):

    marks.append(m)

def POP( ):

    if marks == []:

        print(“Empty Stack”)

    else:

        p = marks.pop()

        print(p)

#to invoke push for five times

print(“PUSHING”)

for a in range(5):

    num = int(input(“Enter Number : “))

    PUSH(num)

#to invoke pop for six times

print(“POPPING”)

for a in range(6):

    POP()

Output:

PUSHING

Enter Number : 1

Enter Number : 4

Enter Number : 6

Enter Number : 2

Enter Number : 3

POPPING

3

2

6

4

1

Empty Stack

  B.  Complete the following database connectivity program by writing missing statements and perform  the given query.                                                                                                                                   (4)

import  ______________________________ as sqltor                              # 1

      mycon = sqltor.________( host = “localhost”, user = “root”, passwd = “123”, database = “medicine” )                                                                                                #2

      cursor = mycon.cursor( )

      cursor.execute(______________________ )                               #3

      data = cursor._________________                                                            #4

      for rec in data:

                   print ( rec )

       mycon.close( )

  1. Complete the statement #1,by writing the name of library / package need to import for database connectivity.
  2. Complete the statement #2, write the name of method require to create connection between python and mysql.
  3. Complete the statement #3, write the query to display those drug records which price is between the 50 to 100 from table DRUG.
  4. Complete the statement #4, to retrieve all records from the result set.                       

Answer:

import  mysql.connector as sqltor                           # Statement 1

      mycon = sqltor.connect( host = “localhost”, user = “root”, passwd = “123”, database = “medicine” )                                                            # Statement 2

      cursor = mycon.cursor( )

      cursor.execute(“SELECT * FROM DRUG WHERE PRICE BETWEEN 50 AND 100” )                                                                             # Statement 3

      data = cursor.fetchall()                                            # Statement 4

      for rec in data:

                   print ( rec )

       mycon.close( )

Sorry! You cannot copy content of this page. Please contact, in case you want this content.

Scroll to Top