You are on page 1of 5

OUTPUT 1: Practical No.

18

Enter list elements=[10,20,30,40] OBJECTIVE:-


Write a program to input a list of N numbers and
swap elements at the even location with the
Original list= [10, 20, 30, 40]
elements at the odd location.
Swapped list= [20, 10, 40, 30]
SOURCE CODE:-
OUTPUT 2:
n=eval(input('Enter list elements='))
Enter list elements=[55,66,77,88,99] print()
print('Original list=',n)
Original list= [55, 66, 77, 88, 99] t=n
Swapped list= [66, 55, 88, 77, 99] lnth=len(t)
if lnth%2 != 0:
lnth=lnth-1
for i in range(0,lnth,2):
t[i],t[i+1]=t[i+1],t[i]

print("Swapped list=",t)
OUTPUT 1: Practical No. 19

How many employees=2 OBJECTIVE:-


Write a program to create a dictionary with empno,
Enter details of employee 1 name and salary of N employees and display the name
of employees who have salary>10000.
Emp ID=1999
Name=SChaubey SOURCE CODE:-
Salary=90000 n=int(input("How many employees="))
emp={ }
Enter details of employee 2 for i in range(1,n+1):
print("Enter details of employee",(i))
empno=int(input('Emp ID='))
Emp ID=2888 ename=input('Name=')
Name=RPatil esal=float(input('Salary='))
d={'EID':empno,'Ename':ename, 'Esalary':esal}
Salary=8800 key="Emp"+str(i)
emp[key]=d
Employees with salary>10000 print("Employees with salary>10000")
for i in range(1,n+1):
key="Emp"+str(i)
{'EID': 1999, 'Ename': 'SChaubey', 'Esalary': 90000.0} if emp[key]['Esalary']>10000:
print(emp[key])
Practical No. 20
OUTPUT 1:
OBJECTIVE:-
Write a program to deposit scholarship amount
How many students=3 Rs.3000/- to all students using dictionary.

Enter roll no=24 SOURCE CODE:-


Enter roll no=26 L=[]
n=int(input('How many students='))
Enter roll no=29
for i in range(n):
Selected students getting scholarship r=int(input('Enter roll no='))
{24: 3000, 26: 3000, 29: 3000} L.append(r)

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 | |
+---------+---------------+--------+------+---------+-------+

You might also like