Professional Documents
Culture Documents
NO PROGRAM REMARK
S
1 Print highest and lowest
2 Ascending & descending
3 Reverse order
4 Counting no. of positive
and negative values in
tupple
5 Counting no. of even and
in tupple
6 Dictionary (Printing
phone no.)
7 Phone no. of friend name
aman in dictionary
8 Add 2 to even and 3 to
odd in list
9 NO. IN REVERSE Count
no. of even values in list
10 Print first and last
element in list
11 Add 1 to even and 2 to
odd
12 SQL 1
13 SQL 2
14 SQL 3
15 SUM OF NO.S DIVISIBLE
BY 5
Q.1 WAP a program to input 10 elements in a list .
Print the highest and second highest number.
Source code:
L=[]
for i in range(10):
n=int(input("enter a number:"))
L.append(n)
a=max(L)
print("highest number is:",a)
L.remove(a)
print("second highest number is:",max(L))
Output:
Q.2 WAP to input n elements in a list. Print the list in
ascending and descending order.
Source code:
L=[]
n=int(input("enter no of elements:"))
for i in range(n):
e=int(input("enter elements:"))
L.append(e)
L.sort()
print("ascending order:",L)
L.sort(reverse=True)
print("descending order:",L)
Output:
Q.3 WAP to input n elements in a list. Print the list in
reverse order.
Source code:
L=[]
n=int(input("enter no of elements:"))
for i in range(n):
e=input("enter elements:")
L.append(e)
L.reverse()
print(L)
Output:
Q.4 WAP to input n elements in a tuple.Count and
print positive,negative and zeroes entered.
Source:
n=int(input("enter no of elements:"))
t=()
for i in range(n):
num=int(input("enter a number:"))
t=t+(num,)
print(t)
c=0
m=0
k=0
for j in t:
if j>0:
c=c+1
elif j<0:
m=m+1
else:
k=k+1
print("positive numbers entered are:",c)
print("negative numbers entered are:",m)
print("zeroes entered are:",k)
Output:
Q.5 WAP to input 10 elements in a tuple count and
print even numbers entered.
Source:
t=()
c=0
for i in range(10):
n=int(input("enter a number:"))
t=t+(n,)
for j in t:
if j%2==0:
c=c+1
Source:
friend={}
for i in range(5):
name=str(input("enter a name:"))
phono=int(input("enter a phone number:"))
friend[name]=phono
a=friend.values()
b=list(a)
print(b[1])
Output:
Q.7 WAP to create a dictionary named directory with
having n values as name and phone no . Print the
phone no of all users stored with the name “aman”.
Source:
directory={}
for i in range(5):
name=str(input("enter name:"))
phono=int(input("enter phono:"))
directory[name]=phono
a="aman"
if a in directory:
print(directory.get(a))
Output:
Source code:
L=[]
n=int(input("enter no of elements you want to add:"))
for i in range(n):
num=int(input("enter a number:"))
if i%2!=0:
num=num+1
else:
num=num+2
L.append(num)
print(L)
Output:
Q.12
1)Write a command to create table member with all fields
and constraints , member id , member name ,type of
membership , mobile no .
Create table member
(member_id int primary key,member_name varchar(30) not null ,
type_of_membership varchar(50), mobno char(10));
2)Write a command to display the structure of the table
Desc member ;
3)Write a command to add a new column membership fee
Alter table member Add memfee float(10,2);
4)Write a command to change the size of the column TOM to
varchar(50) and not null Alter table member
Modify type_of_membership varchar(50) Not null;
5)Write a command to remove column TOM from the table
Alter table member Drop type_of_membership;
6)Write a command to add a record in the member
Alter table member Insert into member Values (1,”ayush”,’8382727360”,7000);
7)Write a command to display all commands from the table
member
Select * from member;
Q.13
1)Write a command to create database voter
Create database voter;
2)Command to display all databases
Show databases;
3)Create table named data with the following fields VID
(primary key),V name, DOB, address
Create table data(Vno int primary key, vname varchar(30),DOB date, address
varchar(30));
4)Display the structure of voter table
Desc voter;
5)Add a new column named annual income in the voter
table
Alter table voter Add A_income int;
6)Modify the size of vname column as varchar(50)
Alter table voter Modify vname varchar(50);
7)Add any 5 records in the voter table
Insert into voter Values (1,”ayush”,”2006-12-6”,”sector-61”,7000);
8)Display Vid and Vname of all the voters
Select Vid,Vname from voter;
9)Display the details of all the voters whose income is more
than 2 lakh
select* from voter Where A_income>200000;
Q.14
Source:
L=[]
for i in range(10):
n=int(input("enter a number:"))
L.append(n)
c=0
for j in L:
if j%5==0:
c=c+j
print("sum of numbers divisible by 5 is:",c)
Output: