Kendriya Vidyalaya NO. 2 Session: 2022-2023 Class: 12 - A Computer Science Practical File

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 24

KENDRIYA VIDYALAYA

NO. 2
Session: 2022-2023
Class: 12th-A
Computer Science
Practical File

Submitted by: Aayush Raj


Submitted to: Mrs Sangeeta Pal
Roll no.:21674577

1
CERTIFICATE

This is to certify that Aayush Raj of class


XII-A (Science) of Kendriya Vidyalaya No.2
AFS Hindon has completed his Practical File
of Computer Science under my Supervision.
He has taken proper care and showed his
utmost sincerity for the completion of this
practical file. I certify that this practical file
is up to my expectations and as per the CBSE
guidelines.

Teacher's signature External Examiner

2
INDEX

CERTIFICATE
String Questions
List Questions
Tuple Questions
Function Question
File Handling Questions
SQL Questions

3
String Questions

Q1) Write a program to check the string entered by the user is


palindrome.

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

Q5) Write a program to enter 'n' number of list elements from


the user and print the reverse of the list element without using
list function.

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

Q9) Write a program to print the max value of a tuple without


using function.

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

Q12) Write a program to pass string as a parameter and print


the reverse of the string without using any string function.

15
Q13) Write a program to pass a no. as a parameter and check the
no. is prime or not

16
File Handling Questions

Q14) Write a program to create a csv file and add information


about the employees

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:

INSERT INTO VEHICLE VALUES(105, 'VAN',NULL);

Output:

19
Q17) Display the Trainer name, City, Salary in descending
order of their
Hiredate.

Query:

SELECT TNAME,CITY,SALARY FROM TRAINER ORDER BY


HIREDATE DESC;

Output:

20
Q18) Display TNAME and CITY of the Trainer who joined the
institute in the month of December 2001.

Query:

SELECT TNAME,CITY FROM TRAINER WHERE HIREDATE


BETWEEN '2001-12-01' AND '2001-12-31’;

Output:

21
Q19. To display number of courses in each city

Query:

SELECT TRAINER.CITY, COUNT(COURSE.CNAME) FROM TRAINER,


COURSE
WHERE COURSE. TID = TRAINER. TID GROUP BY TRAINER.CITY;

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("CREATE DATABASE LVIS")

curs.execute("USE LVIS")

curs.execute("CREATE TABLE CSBATCH(ID INTEGER PRIMARY KEY,

NAME CHAR(20), MARKS INTEGER, CLASS CHAR(1))")

data = [

[1,"Rijak",98,"a"],

[2,"Tijak",88,"b"],
23
[3,"Jijak",78,"a"],

[4,"Mijak",68,"b"],

[5,"Sijak",28,"a"],

curs.executemany("INSERT INTO CSBATCH VALUES (%s, %s,

%s,%s)",data)

myc.commit()

curs.execute("SELECT * FROM CSBATCH")

print(curs.fetchall())

Output:

24

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy