Kendriya Vidyalaya NO. 2 Session: 2022-2023 Class: 12 - A Computer Science Practical File
Kendriya Vidyalaya NO. 2 Session: 2022-2023 Class: 12 - A Computer Science Practical File
Kendriya Vidyalaya NO. 2 Session: 2022-2023 Class: 12 - A Computer Science Practical File
NO. 2
Session: 2022-2023
Class: 12th-A
Computer Science
Practical File
1
CERTIFICATE
2
INDEX
CERTIFICATE
String Questions
List Questions
Tuple Questions
Function Question
File Handling Questions
SQL Questions
3
String Questions
4
Q2) Write a program to check the string entered by the user
contains vowels or not.
5
Q3) Write a program to count the occurence of substring in
the main string.
6
Q4) Write a program to count the no. of spaces, alphabets,
digits, in a string.
7
List Questions
8
Q6) Write a program to input 'n' number of list elements from
the user and shift the even elements of the list to the right and
odd to the left.
9
Q7) Write a program to create 2 nested list whose total numbers
of rows and columns entered by the user and also elements
entered by the user perform addition of 2 nested list and store
the result in new nested list
10
Q8) Write a program to create a nested list whose total number of
rows and columns entered by the user and also the element
entered by the user
11
Tuple Questions
12
Q10) Write a program to print the even position element of
the tuple
13
Q11) Write a program to print sum of the even element of
the tuple and product of the odd element of the tuple.
14
Function Questions
15
Q13) Write a program to pass a no. as a parameter and check the
no. is prime or not
16
File Handling Questions
17
Q15) A binary file “STU.DAT” has structure (admission number,
Name, Percentage).
18
SQL QUESTIONS
Q16) Write the SQL command to insert the following data into
the
attributes CODE and VTYPE respectively in the given table
VEHICLE. CODE = 105 and VTYPE="VAN".
Query:
Output:
19
Q17) Display the Trainer name, City, Salary in descending
order of their
Hiredate.
Query:
Output:
20
Q18) Display TNAME and CITY of the Trainer who joined the
institute in the month of December 2001.
Query:
Output:
21
Q19. To display number of courses in each city
Query:
Output:
22
Q20. Write a single program to perform the following functions using
interface of python with MySQL:
• Create a connection
• Create a new database (LVIS)
• Create a new table (CSBATCH) with minimum four columns
indatabase (LVIS)
• Insert minimum 5 rows in table (CSBATCH)
• Display all rows of table (CSBATCH)
Code:
import mysql.connector
myc = mysql.connector.connect(user="root",password="1289")
curs = myc.cursor()
curs.execute("USE LVIS")
data = [
[1,"Rijak",98,"a"],
[2,"Tijak",88,"b"],
23
[3,"Jijak",78,"a"],
[4,"Mijak",68,"b"],
[5,"Sijak",28,"a"],
%s,%s)",data)
myc.commit()
print(curs.fetchall())
Output:
24