0% found this document useful (0 votes)
8 views30 pages

Cs Practical

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views30 pages

Cs Practical

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

DELHI PUBLIC SCHOOL ,GWALIOR

Submitted by:- Kshitij Choudhary


XII-C
Certificate

This is certified that Kshitij Choudhary of class XII


has successfully completed the Computer Science
Practical under my guidance in the academic
session 2024-25.

He has taken proper care and shown utmost


sincerity in completing his practicals.

I certify that this practical skill is up to my expectations


and as per the guidelines issued by the Central Board of
Secondary Education.

Mr. Ajay Tomar

(PGT Computer Science)


I would like to express my deep sense of Thanks and
Gratitude to my Computer Science Educator Mr.
Ajay Tomar for guiding me as well as motivating me
through the course of the practicals. He always
evinced keen interest in my work. His constructive
and constant motivation helped me in successfully
completing my practicals.

My sincere thanks go to Ms. Gayatri Shrivastava ,


the Principal of our school for extending every
possible support and environment for completing
my Computer Science practicals.

Kshitij Choudhary

XII-C
Program:-1

Write a Python Program to find sum of two


numbers

Source Code:-

Output
Program:- 2

Write a python program to find whether the


given no. is prime no.

Source Code:-

Output
Program 3:-

Write a program to find whether the number is


even or odd

Source Code:-

Output
Program 3:-

Write a program to create a menu driven


program to perform arithmetic operations

Source Code:-

Output
Program 4:-

Write a program swap values of two variables


without use of third variable.

Source Code:-

Output
Program 5:-

Write a program to generate random number


between 1 to 6 to create a dice

Source Code:-

Output
Program 6:-

Write a program to check if the given number is a


palindrome or not.

Source Code:-

Output
Program 7:-

Write a program to calculate perimeter and area


of rectangle

Source Code:-

Output
Program 8:-

Write a program to How to check if a given


number is Fibonacci number?

Source Code:-

Output
Program 9:-

Write a program to convert degree celsius to


degree fahrenheit

Source Code:-

Output
Program 10:-

Write a program to find whether the given year


is leap year or not

Source Code:-

Output
Program 11:-

Write a program to find root of quadratic


equation

Source Code:-

Output
Program 12:-

Write a program to make the following sequence

12

123:-

Source Code:-

Output
Program 13:-

Write a program to print following pattern

333

22

1
Source Code:-

Output
Program 14:-

Write a program to HCF of two numbers

Source Code:-

Output
Program 15:-

Write a program to make pyramid using “*”

Source Code:-

Output
Program 12:-

Write a program to make the following sequence

12

123:-

Source Code:-

Output
MySQL Query 1:-

select * from cars where type='F1 Car’;

select distinct type from cars;


MySQL Query 2:-

Select * from employee where desig=‘programmer’

Select * from employee where salary>=100000


MySQL Query 3:-

(i) To display the details of those Clients whose city is


Delhi
(ii) To display the details of Products whose Price is in the
range of 50 to 100 (both values included).

ANS:-
i) SELECT * FROM CLIENT WHERE City="Delhi";

(ii) SELECT * FROM PRODUCT WHERE Price BETWEEN 50


and 100;
MySQL Query 4:-

(i) To display details of all models in the Model table in


ascending order of Date Of Manufacture

(ii) To display details of those models manufactured in


2011 and whose Cost is below 2000.

ANS:-
i. SELECT * FROM Model ORDER BY
DateOfManufacture;

ii. SELECT * FROM Model WHERE year


(DateOfManufacture) = 2011 AND Cost < 2000;
MySQL Query 5:-

(i) Display the Maximum Interest from Loans table.

(ii) Display the count of all loan holders whose name


ends with 'Sharma'.

ANS:-
i. SELECT MAX(Interest) FROM LOANS;

ii. SELECT COUNT(*) FROM LOANS WHERE Cust Name


LIKE '%Sharma';
# Write a program to connect Python with MySQL using
database connectivity and perform the following
operations on data in database: Fetch, Update and
delete the data.

1. CREATE A TABLE

import mysql.connector
demodb = mysql.connector.connect(host="localhost",
user="root",
passwd="computer", database="EDUCATION")
democursor=demodb.cursor( )
democursor.execute("CREATE TABLE STUDENT (admn_no int
primary key,
sname varchar(30), gender char(1), DOB date, stream
varchar(15), marks float(4,2))")
2. INSERT THE DATA

import mysql.connector
demodb = mysql.connector.connect(host="localhost",
user="root",
passwd="computer", database="EDUCATION")
democursor=demodb.cursor( )
democursor.execute("insert into student values (%s, %s,
%s, %s, %s, %s)",
(1245, 'Arush', 'M', '2003-10-04', 'science', 67.34))
demodb.commit( )
3.FETCH THE DATA

import mysql.connector
demodb = mysql.connector.connect(host="localhost",
user="root",
passwd="computer", database="EDUCATION")
democursor=demodb.cursor( )
democursor.execute("select * from student")
for i in democursor:
print(i)
D. UPDATE THE RECORD

import mysql.connector
demodb = mysql.connector.connect(host="localhost",
user="root",
passwd="computer", database="EDUCATION")
democursor=demodb.cursor( )
democursor.execute("update student set marks=55.68
where admn_no=1356")
demodb.commit( )
E. DELETE THE DATA

import mysql.connector
demodb = mysql.connector.connect(host="localhost",
user="root",
passwd="computer", database="EDUCATION")
democursor=demodb.cursor( )
democursor.execute("delete from student where
admn_no=1356")
demodb.commit()

You might also like