Computer Science Practical Question Paper Sample

A.I.S.S.C.E. Practical Examination

Subject: Computer Science (083)

Time 3 Hrs/MM:30

 

SET- 1

1- Write a program to input a list and interchange first with last, second with second last …. Print the list in reverse order.(7 marks)

2- Write a program to create interface with MySQL database and increase the fees by 1000 of section A students of table CBSE21 ( which is already stored in test database).(5 marks)

 

ROLLNO  NAME  ADMN  SEC  TID  FEES
1  AJAY 1234  A 111 1000
2  AJEEM 1212  A 112 1200
3  SHREE 1219  C 115 1200
4  RAVI 1216  C 115 1250
5  SOHAN 2212  B 119 1300
6  ARSH 1212  A 112 1200
7  RISHI 1230  C 130 1200
8  CHIRAG 1290  B 187 1100
9  VINAYAK 1345  B 213 1600
10  RAJNEESH 4212  A 111 1200

 

Solution:

#python -m pip install mysql-connector-python
#install it from python directory 
import mysql.connector
mycon=mysql.connector.connect(host="localhost",user="root",password="100",database="test")
if(mycon.is_connected):
    print("python connected  with SQL ")
else:
    print("not connected with SQL")
mycursor=mycon.cursor()
mycursor.execute("update dma23 set fees=fees+1000 where sec='A'")
mycon.commit()

'''

 

3- Project (8 marks)

4- Practical File (7 marks)

5- Viva (3 marks)

 

 

SET 2

1- Write a program  to input a list and replace every even element with its half and odd with double. (7 marks)

2- Write a program to create interface with MySQL database and display name , fees and new fees where new fees is 100 + fees  in  table CBSE21 ( which is already stored in test database).(5 marks)

 

ROLLNO  NAME  ADMN  SEC  TID  FEES
1  AJAY 1234  A 111 1000
2  AJEEM 1212  A 112 1200
3  SHREE 1219  C 115 1200
4  RAVI 1216  C 115 1250
5  SOHAN 2212  B 119 1300
6  ARSH 1212  A 112 1200
7  RISHI 1230  C 130 1200
8  CHIRAG 1290  B 187 1100
9  VINAYAK 1345  B 213 1600
10  RAJNEESH 4212  A 111 1200

 

Solution:

#python -m pip install mysql-connector-python
#install it from python directory 
import mysql.connector
mycon=mysql.connector.connect(host="localhost",user="root",password="100",database="test")
if(mycon.is_connected):
    print("python connected  with SQL ")
else:
    print("not connected with SQL")
mycursor=mycon.cursor()
mycursor.execute("SELECT NAME,FEES,FEES+100 FROM DMA23")
for x in mycursor:
    print(x)

 

 

3- Project (8 marks)

4- Practical File (7 marks)

5- Viva (3 marks)

 

 

SET 3

1- Write a program  to input a list and interchange its alternate elements 1,2,3,4,5,6-> 2,1,4,3,6,5 (7 marks)

2- Write a program to create interface with MySQL database and display how many students in section C  from   table CBSE21 ( which is already stored in test database). (5 marks)

 

ROLLNO  NAME  ADMN  SEC  TID  FEES
1  AJAY 1234  A 111 1000
2  AJEEM 1212  A 112 1200
3  SHREE 1219  C 115 1200
4  RAVI 1216  C 115 1250
5  SOHAN 2212  B 119 1300
6  ARSH 1212  A 112 1200
7  RISHI 1230  C 130 1200
8  CHIRAG 1290  B 187 1100
9  VINAYAK 1345  B 213 1600
10  RAJNEESH 4212  A 111 1200

 

Solution:

#python -m pip install mysql-connector-python
#install it from python directory 
import mysql.connector
mycon=mysql.connector.connect(host="localhost",user="root",password="100",database="test")
if(mycon.is_connected):
    print("python connected  with SQL ")
else:
    print("not connected with SQL")
mycursor=mycon.cursor()
mycursor.execute("select count(*) from dma23 where sec='c'")
for x in mycursor:
    print(x)

 

3- Project (8 marks)

4- Practical File (7 marks)

5- Viva (3 marks)

 

 

SET 4

1- Write a program  to input a list and replace  all those numbers with their next list element which are divisible by 3.

3 4 6 1 2 3 8= 4 4 1 1 2 8 8 (7 marks)

2- Write a program to create interface with MySQL database and display how many students in each section where strength is more then 2 from   table CBSE21 ( which is already stored in test database).(5 marks)

 

ROLLNO  NAME  ADMN  SEC  TID  FEES
1  AJAY 1234  A 111 1000
2  AJEEM 1212  A 112 1200
3  SHREE 1219  C 115 1200
4  RAVI 1216  C 115 1250
5  SOHAN 2212  B 119 1300
6  ARSH 1212  A 112 1200
7  RISHI 1230  C 130 1200
8  CHIRAG 1290  B 187 1100
9  VINAYAK 1345  B 213 1600
10  RAJNEESH 4212  A 111 1200

 

Solution:

#python -m pip install mysql-connector-python
#install it from python directory 
import mysql.connector
mycon=mysql.connector.connect(host="localhost",user="root",password="100",database="test")
if(mycon.is_connected):
    print("python connected  with SQL ")
else:
    print("not connected with SQL")
mycursor=mycon.cursor()
mycursor.execute("select sec,count(*) from dma23 group by sec having count(*)>2")
for x in mycursor:
    print(x)

 

3- Project (8 marks)

4- Practical File (7 marks)

5- Viva (3 marks)

 

SET 5

1- WRITE A PROGRAM to input a list of numbers and print its largest , smallest  with their index. (7 marks)

Input->How many elements- 6

Enter elements 19,34,24,89,45,12

Largest – 89 index 3

Smallest –  12 index 5

2- Write a program to create interface with MySQL database and display names of students whose name length is only 4 from   table CBSE21 ( which is already stored in test database). (5 marks)

 

ROLLNO  NAME  ADMN  SEC  TID  FEES
1  AJAY 1234  A 111 1000
2  AJEEM 1212  A 112 1200
3  SHREE 1219  C 115 1200
4  RAVI 1216  C 115 1250
5  SOHAN 2212  B 119 1300
6  ARSH 1212  A 112 1200
7  RISHI 1230  C 130 1200
8  CHIRAG 1290  B 187 1100
9  VINAYAK 1345  B 213 1600
10  RAJNEESH 4212  A 111 1200

 

Solution:

#python -m pip install mysql-connector-python
#install it from python directory 
import mysql.connector
mycon=mysql.connector.connect(host="localhost",user="root",password="100",database="test")
if(mycon.is_connected):
    print("python connected  with SQL ")
else:
    print("not connected with SQL")
mycursor=mycon.cursor()
mycursor.execute('select name from dma23 where name like "____"')
for x in mycursor:
    print(x)


'

 

3- Project (8 marks)

4-Practical File (7 marks)

5-Viva (3 marks)

 

 

SET 6

1- Create a function to take a number as argument return 1 if number is prime , return 0 if number is not prime. Call this function to print prime number between 5 to 50. (7 marks)

2- Write a program to create interface with MySQL database and display all data of A section students  from table CBSE21 ( which is already stored in test database) (5 marks)

 

ROLLNO  NAME  ADMN  SEC  TID  FEES
1  AJAY 1234  A 111 1000
2  AJEEM 1212  A 112 1200
3  SHREE 1219  C 115 1200
4  RAVI 1216  C 115 1250
5  SOHAN 2212  B 119 1300
6  ARSH 1212  A 112 1200
7  RISHI 1230  C 130 1200
8  CHIRAG 1290  B 187 1100
9  VINAYAK 1345  B 213 1600
10  RAJNEESH 4212  A 111 1200

 

Solution:

#python -m pip install mysql-connector-python
#install it from python directory 
import mysql.connector
mycon=mysql.connector.connect(host="localhost",user="root",password="100",database="test")
if(mycon.is_connected):
    print("python connected  with SQL ")
else:
    print("not connected with SQL")
mycursor=mycon.cursor()
mycursor.execute('select * from dma23 where sec="A" ')
for x in mycursor:
    print(x)

 

3- Project (8 marks)

4- Practical File( 7 marks)

5- Viva (3 marks)

 

SET 7

1- WRITE A PROGRAM to read a text file “ab.txt” and count how many “he “ and “she” are there. ( 7 marks)

2- Write a program to create interface with MySQL database and display how many students in section A and their average fees from   table CBSE21 ( which is already stored in test database). (5 marks)

 

ROLLNO  NAME  ADMN  SEC  TID  FEES
1  AJAY 1234  A 111 1000
2  AJEEM 1212  A 112 1200
3  SHREE 1219  C 115 1200
4  RAVI 1216  C 115 1250
5  SOHAN 2212  B 119 1300
6  ARSH 1212  A 112 1200
7  RISHI 1230  C 130 1200
8  CHIRAG 1290  B 187 1100
9  VINAYAK 1345  B 213 1600
10  RAJNEESH 4212  A 111 1200

 

Solution:

#python -m pip install mysql-connector-python
#install it from python directory 
import mysql.connector
mycon=mysql.connector.connect(host="localhost",user="root",password="100",database="test")
if(mycon.is_connected):
    print("python connected  with SQL ")
else:
    print("not connected with SQL")
mycursor=mycon.cursor()
mycursor.execute('select count(*),avg(fees) from dma23 where sec="A" ')
for x in mycursor:
    print(x)

 

3- Project (8 marks)

4- Practical File (7 marks)

5- Viva (3 marks)

 

SET 8

1- WRITE A PROGRAM to read a text file my.txt and count how many upper case character and how many lower case character are there. (7 marks)

2- Write a program to create interface with MySQL database and display names which are ending with ‘N’  in alphabetical order table CBSE21 ( which is already stored in test database). (5 marks)

 

ROLLNO  NAME  ADMN  SEC  TID  FEES
1  AJAY 1234  A 111 1000
2  AJEEM 1212  A 112 1200
3  SHREE 1219  C 115 1200
4  RAVI 1216  C 115 1250
5  SOHAN 2212  B 119 1300
6  ARSH 1212  A 112 1200
7  RISHI 1230  C 130 1200
8  CHIRAG 1290  B 187 1100
9  VINAYAK 1345  B 213 1600
10  RAJNEESH 4212  A 111 1200

 

Solution:

#python -m pip install mysql-connector-python
#install it from python directory 
import mysql.connector
mycon=mysql.connector.connect(host="localhost",user="root",password="100",database="test")
if(mycon.is_connected):
    print("python connected  with SQL ")
else:
    print("not connected with SQL")
mycursor=mycon.cursor()
mycursor.execute('select name  from dma23 where name like "%N" order by name')
for x in mycursor:
    print(x)

 

3- Project (8 marks)

4- Practical File (7 marks)

5- Viva( 3 marks)

 

SET 9

1- WRITE A PROGRAM to read a  text file  and count how many vowels(both case) are there. (7 marks)

2- Write a program to create interface with MySQL database and  insert  a new record (18,”Dev”, 8978,’A’ 115, 1400) in   table CBSE21 ( which is already stored in test database).(5 marks)

 

ROLLNO  NAME  ADMN  SEC  TID  FEES
1  AJAY 1234  A 111 1000
2  AJEEM 1212  A 112 1200
3  SHREE 1219  C 115 1200
4  RAVI 1216  C 115 1250
5  SOHAN 2212  B 119 1300
6  ARSH 1212  A 112 1200
7  RISHI 1230  C 130 1200
8  CHIRAG 1290  B 187 1100
9  VINAYAK 1345  B 213 1600
10  RAJNEESH 4212  A 111 1200

 

Solution:

#python -m pip install mysql-connector-python
#install it from python directory 
import mysql.connector
mycon=mysql.connector.connect(host="localhost",user="root",password="100",database="test")
if(mycon.is_connected):
    print("python connected  with SQL ")
else:
    print("not connected with SQL")
mycursor=mycon.cursor()
R=[]
N=[]
AD=[]
S=[]
T=[]
F=[]
I=0
R.append(18)
N.append("Dev")
AD.append(8978)
S.append('A')
T.append(115)
F.append(1400)
mycursor.execute("INSERT INTO CBSE21(rollno,name,admn,sec,tid,fees) VALUES({},'{}',{},'{}',{},{})".format(R[I],N[I],AD[I],S[I],T[I],F[I]))
mycon.commit()
print(mycursor.rowcount,"RECORD INSERTED")

 

3- Project (8 marks)

4- Practical File ( 7 marks)

5- Viva (3 marks)

 

SET 10

1- WRITE A PROGRAM to create a dictionary to store name, roll no and admission number  and store this dictionary in a binary file my.dat for five students . (7 marks)

2- Write a program to create interface with MySQL database and display number of students, fees total  for each section from   table CBSE21 ( which is already stored in test database). (5 marks)

 

ROLLNO  NAME  ADMN  SEC  TID  FEES
1  AJAY 1234  A 111 1000
2  AJEEM 1212  A 112 1200
3  SHREE 1219  C 115 1200
4  RAVI 1216  C 115 1250
5  SOHAN 2212  B 119 1300
6  ARSH 1212  A 112 1200
7  RISHI 1230  C 130 1200
8  CHIRAG 1290  B 187 1100
9  VINAYAK 1345  B 213 1600
10  RAJNEESH 4212  A 111 1200

 

Solution:

#python -m pip install mysql-connector-python
#install it from python directory 
import mysql.connector
mycon=mysql.connector.connect(host="localhost",user="root",password="100",database="test")
if(mycon.is_connected):
    print("python connected  with SQL ")
else:
    print("not connected with SQL")
mycursor=mycon.cursor()
mycursor.execute('select sec,count(*),sum(fees) from cbse21 group by sec')
for x in mycursor:
    print(x)

''

 

3- Project (8 marks)

4- Practical File (7 marks)

5- Viva (3 marks)

 

Copywrite © 2020-2024, CBSE Python,
All Rights Reserved
error: Content is protected !!