Class-11-Practical-18-21 KV
Class-11-Practical-18-21 KV
Class-11-Practical-18-21 KV
18
print("Swapped list=",t)
OUTPUT 1: Practical No. 19
S=dict.fromkeys(L,3000)
print("Selected students getting scholarship ")
print(S)
Table: Books Practical No. 21
BID BName Price Qty
OBJECTIVE:-
F101 Physics 355 5
Consider the table “Books” and perform SQL queries
F102 Chemistry 650 20
F103 Maths 350 10
SQL queries
F104 CS 750 15
Query-1 To create the table with BID as primary key
Query 2: Sol- create table books
BName Price (bid varchar(4) primary key not null,
Chemistry 650 Bname varchar(15),
CS 750 Price int(5),
Qty int(2));
Query 3:
BName Price Qty Query-2 To show book name and price of books having
Maths 350 10 qty more than 10
Physics 355 5 Sol- select bname, price from books where qty>10;
Chemistry 650 20
Query-3 To display names, price and qty in ascending
CS 750 15
order of their price
Sol- select bname, price, qty from books
order by price;
PTO…
Query-4: Practical No. 21
BID BName Price Qty
F101 Physics 395 5 Contd…
F102 Chemistry 700 20
F103 Maths 400 10
SQL Queries
F104 CS 800 15
Query-5:
+---------+----------------+-------+------+---------+-------+
Query-4 To increase price of all books by 50 rupees
| Field | Type | Null | Key | Default | Extra |
+---------+----------------+-------+------+---------+-------+
Sol- update books set price=price+50;
| bno | int(4) | NO | PRI | NULL | |
| bname | varchar(10) | YES | | NULL | | Query-5 To display the structure of table
| publ | varchar(7) | YES | | NULL | |
| price | int(5) | YES | | NULL | | Sol- desc books;
+---------+---------------+--------+------+---------+-------+
Query-6 To add a new column "Discount" in the table
Query-6:
+---------+----------------+-------+------+---------+-------+ Sol- alter table books add discount int(2);
| Field | Type | Null | Key | Default | Extra |
+---------+----------------+-------+------+---------+-------+
| bno | int(4) | NO | PRI | NULL | |
| bname | varchar(10) | YES | | NULL | |
| publ | varchar(7) | YES | | NULL | |
| price | int(5) | YES | | NULL | |
| discount | int(2) | YES | | NULL | |
+---------+---------------+--------+------+---------+-------+