You are on page 1of 20

COMPUTER SCIENCE

Practical File

KENDRIYA VIDYALAYA INS HAMLA

R.Srikrishna kashyap
Class - XII-A
Roll No -31
CERTIFICATE

Class: XII-A Year:2021-22

This is to certify the work entered


in this file is work of R.Srikrishna
kashyap of Class XII-A Roll No
15609862 has satisfactorily completed
the required number of practical and
worked for the 2nd term of the year
2021-22 in the school laboratory as
laid down by CBSE.

External Examiner Subject Teacher

Principal
Database Management System

1. Creating a Database
Command: create database bank;

2. Creating tables inside the database


# Branch
Create table branch
( Branch_name vaerchar (30),
Branch city Varchar (30),
Assets bigint) ;

# Account
Create table accounts
( Account_no int Primary keys
Branch_name Varchar (30)
Balance int ) ;

# Customer
Create table Customer
( Customer_name Varchar (30) ,
Customer_city Varchar (30)
Customer_Street Varchar(30));

# Depositer
Create table Depositer
( Customer name Varchar(30),
Account no int):

#Loan
Create table loan
( loan_no int primary key,
Branch_name varchar(30),
Loan_amount int);

#Borrower
Create table borrower
(laon_no int primary key,
Customer_name varchar(45));

3. Inserting Values/data into the tables which were


created
# Branch
Insert into branch values
(‘Malad West’,’Mumbai’,’225175688’),
(‘Connaught place’,’Delhi’,182537599),
(‘Vaishali Nagar’,’Jaipur’,192134523);
# Accounts
Insert into account values
(5000, ‘Malad West’,535698),
(5001,‘ ‘Malad West’,450000),
(5002, ‘Malad West’,1225433),
(6001, ‘Connaught place’,745425),
(6002, ‘Connaught place’,978534),
(7001, ‘Connaught place’, 723543),
(7002, ‘Vaishali Nagar’,978654);

#Customer
Insert into customer values
(‘Devaram’ , ‘Malwani No.1’, ‘Mumbai’),
(‘Asha Waghmare’ , ‘jankalyan nagar’ , ‘Mumbai’),
(‘Arjun Ram’, ‘Karol Baug’ , ‘New Delhi’),
(‘Shabbana Bano’ , ‘Chandani Chowk’ , ‘New Delhi’),
(‘john’, ‘Mansarovar’, ‘Jaipur’),
(‘Devendra singh’ , ‘Shashtri Nagar’ , ‘Jaipur’),
(‘Laxmi Devi’, ‘Khatipura’ , ‘Jaipur’),
(‘Birbal Ram’ , ‘Dariyaganj’ , ‘New Delhi’),
(‘Dinesh Kumar’ , ‘Malviya Nagar’ , ‘Jaipur’);

# Depositor
Insert into depositor values
(‘Devaram’, 5000),
(‘Asha WAaghnmare’, 5001),
(‘Asha Waghmare’, 5002),
(‘Arjun Ram’, 6001),
(‘Shababana Bano’, 6002),
(‘Devemdra Singh’, 7001),
(‘Laxmi Devi’, 7002);
#Loan
Insert into loan values
(1551 , ‘Malad West’ , 200000)
(1552 , ‘Connaught Place’ , 245000)
(1553 , ‘Vaishali Nagar’ , 567000)
(1554 , ‘Vaishali Nagar’ , 435000)
(1555 , ‘Malad West’, 225000)
(1556 , ‘Vaishali Nagar’, 155000);

#Borrower
Insert into borrower values
( 1551 , ‘Asha Waghmare’ )
( 1552 , ‘shabbana Bano’)
( 1553 , ‘John’ )
( 1554 , ‘Dinesh Kumar’)
( 1555 , ‘Birbal Ram’ )
( 1556 , ‘Laxmi Devi’ );
4. Find the names and street addresses of
customers who belong to New Delhi.
Command: select customer_name,customer_street
from customer where customer_city = ‘new
delhi’;

5. Find the account numbers and balances of


only the accounts at the Connaught Place
branch.
Command: Select account_no,balance from where
branch_name = ‘connaught place’;
6. Find the loan numbers and loan amounts of
loans with amount greater than 500000.
Command: Select loan_no,loan_amount from loan
where loan_amount > 500000;

7. Find the different localities in Jaipur to


where the customers belong.
Command: Select customer_street from customer
where customer_city = ‘Jaipur’;
8. Find the street and city of Asha Waghmare (a
customer of bank).
Command: Select cutomer_street, customer_city
from customer where customer_name = ‘asha
waghmare’

9. Find the account numbers and balances of


only such accounts which have balance between 1
lakh to 5 lakh (both values included).
Command: Select account_no, balance from
account where balance >100000 and balance <
500000;

10. Find branch name and balance of account


number 5234.
Command: Select branch_name,balance from
account where account_no = 5234;
Result: Empty set.

11.Find the names of customer along with branch


names and loan_amount who have borrowed more
than 2 lakhs.
Command: select * from borrower natural join
loan where loan_amount > 200000;

12.Find names of branches, city and assets


which have at least one loan with amount
between 1 lakhs and 5 lakhs .
Command: Select from loan natural join branch
where loan_amount > 100000 and loan_amount <
500000;

13. Find the loan numbers of loans which are


not related to Vaishali Nagar
Command: Select loan_no from loan where
branch_name <> ‘Vaishali Nagar’;
14. Find the names and street of customers who
live either in jankalyan nagar, Mumbai or
masarover, Jaipur.
Command: select customer_name,customer_street
from customer where (customer_street =
‘Jankalyan Nagar’ and city = ‘Mumbai’) or
(customer_street = ‘Mansarovar’ and
customer_city = ‘Jaipur’);

15. Using some math functions on MY-SQL


A table named maths was created with some
random values in it and then power, mod and
round functions were used.
Connectivity With Python

1. Write a program in python which can take


input from the user and update the tables in
bank database in MY-SQL server.

import mysql.connector as mc
con = mc.connect(host = 'localhost', username ='root',
password = 'Rskk@2020',database = 'bank')
cur = con.cursor()

print("1.Account\n2.Branch\n3.Borrower\n4.Customer\n5.D
epositer\n6.Loan")
in1 = int(input("Enter The Number Of The Table: "))

if in1 == 1:
accn = int(input("Enter Account Number: "))
branch = input("Enter Branch Name: ")
balance = int(input("Enter The Balance: "))
cur.execute("insert into account
values({},'{}',{})".format(accn,branch,balance))
con.commit()
print("Data Entered Successfully....")
if in1 == 2:
branch = input("Enter Branch Name: ")
city = input("Enter The City: ")
assets = int(input("Enter Assets: "))
cur.execute("insert into branch values
('{}','{}',{})".format(branch,city,assets))
con.commit()
print("Data Entered Successfully....")
if in1 == 3:
loanno = int(input("Enter Loan Number: "))
Customer_name = input("Enter The Name Of The
Customer: ")
cur.execute("insert into borrower
values({},'{}')".format(loanno,Customer_name))
con.commit()
print("Data Entered Successfully....")
if in1 == 4:
Customer_name = input("Enter The Name Of The
Customer: ")
Customer_city = input("Enter The City Of The
Customer: ")
Customer_street = input("Enter The Street Of The
Customer: ")
cur.execute("insert into customer values
('{}','{}','{}')".format(Customer_name,Customer_city,Cu
stomer_street))
con.commit()
print("Data Entered Successfully....")
if in1 == 5:
Customer_name = input("Enter The Name Of The
Customer: ")
accn = int(input("Enter Account Number: "))
cur.execute("insert into depositer values
('{]',{})".format(Customer_name,accn))
con.commit()
print("Data Entered Successfully....")
if in1 == 6:
loanno = int(input("Enter Loan Number: "))
branch = input("Enter Branch Name: ")
loan_amount = int(input("Enter Loan Amount: "))
cur.execute ("insert into loan values
({},'{}',{})".format(loanno,branch,loan_amount))
con.commit()
print("Data Entered Successfully....")
2. Write a program to show the data present in
the table in bank database where table name is
entered by the user.
import mysql.connector as mc
con = mc.connect(host = 'localhost', username ='root',
password = 'Rskk@2020',database = 'bank')
cur = con.cursor()

in1 = input("Enter The Name Of The Table: ")

cur.execute("Select * from %s"%in1)


y = cur.fetchall()
for i in range (len(y)):
print(y[i])
Data Structures

1. Write a program to push elements inside the


stack and show the top element when asked by
the user.
def isEmpty(Arr):
if len(Arr)==0:
return True
else:
return False
def push(Arr,item):
if item%5==0:
Arr.append(item)
top=len(Arr)-1
def show(Arr):
if isEmpty(Arr):
print('No item found')
else:
t=len(Arr)-1
print('(TOP)',end='')
while(t>=0):
print(Arr[t],'<==',end='')
t=t-1
print()
Arr=[]
top=None
while True:
print('****** STACK IMPLEMENTATION USING LIST
******')
print('1: PUSH')
print('2: Show')
print('0: Exit')
ch=int(input('Enter choice:'))
if ch==1:
val=int(input('Enter no to push:'))
push(Arr,val)
elif ch==2:
show(Arr)
elif ch==0:
print('Bye')
break
---------THE END---------

You might also like