XI IP Practical List 2024-25
XI IP Practical List 2024-25
PRACTICAL FILE
INFORMATICS PRACTICES (065)
CLASS: XI B
(SESSION: 2024-25)
1
PYTHON
Program 1: WAP to input principal amount, rate of interest and time, period & calculate simple
interest.
Code:
p=int(input("Enter Principal amount="))
r=float(input("Enter rate of interest="))
t=int(input("Enter time period in years="))
si=(p*r*t)/100
print("Simple Interest=",si)
Output:
Enter Principal amount=5000
Enter rate of interest=6.5
Enter time period in years=6
Simple Interest= 1950.0
Output:
Enter first number50
Enter first number100
Before swapping the values are= 50 100
After swapping the values are= 100 50
Program 3: WAP in python to check whether a user entered number is even or odd.
Code:
number=int(input("Enter any integer number="))
if number%2==0:
print("The entered number" , number, " is Even")
else:
print("The entered number" , number, " is Odd")
Output:
Enter any integer number=43
The entered number 43 is Odd
2
Program 4: Write a program to display weekday name against a user entered weekday number.
Code:
weekdayno=int(input("Enter day number of week day="))
if weekdayno==1:
print("Monday")
elif weekdayno==2:
print("Tuesday")
elif weekdayno==2:
print("Wednesday")
elif weekdayno==4:
print("Thursday")
elif weekdayno==5:
print("Friday")
elif weekdayno==6:
print("Saturday")
elif weekdayno==7:
print("Sunday")
else:
print("You have entered wrong day number")
Output:
Enter day number of week day=6
Saturday
Program 5: WAP in python to calculate & display the result of a user entered arithmetic operation
done on two user entered numbers.
Code:
num1=int(input("Enter first number="))
num2=int(input("Enter second number, except zero="))
arop=input("Enter arithmetic symbol=")
#For Addition
if arop=='+':
print("The addition of two numbers",num1,num2,"=",num1+num2)
#For subtraction
if arop=='-':
print("The sutraction of two numbers",num1,num2,"=",num1-num2)
#For Product
if arop=='*':
print("The product of two numbers",num1,num2,"=",num1*num2)
#For Quotient
if arop=='/':
print("The quotient of two numbers",num1,num2,"=",num1/num2)
3
#For Floor division
if arop=='//':
print("The quotient in floor division of two numbers",num1,num2,"=",num1//num2)
#For Remainder
if arop=='%':
print("The modulo/remainder of two numbers",num1,num2,"=",num1%num2)
#For Exponent
if arop=='**':
print("The exponentiation of two numbers",num1,num2,"=",num1**num2)
Output:
Enter first number=45
Enter second number, except zero=7
Enter arithmetic symbol=/
The quotient of two numbers 45 7 = 6.428571428571429
Program 6: WAP in python to find the largest value among three user entered values.
Code:
a=int(input("Enter first number="))
b=int(input("Enter second number="))
c=int(input("Enter third number="))
max=a
if b>max:
max=b
if c>max:
max=c
print("The largest number is =", max)
Output:
4
Program 7: WAP in python to find the second largest value among three user entered values.
Code:
a=int(input("Enter first number"))
b=int(input("Enter first number"))
c=int(input("Enter first number"))
if a>b and a>c:
max=a
if b>c:
max1=b
else:
max1=c
elif b>c and b>a:
max=b
if a>c:
max1=a
else:
max1=c
else:
max=c
if b>a:
max1=b
else:
max1=a
print("Second largest=",max1)
Output:
Enter first number65
Enter first number25
Enter first number37
Second largest= 37
Output:
Enter a number6
factorial of number= 6 is 720
5
Output:
Enter a number9
9 18 27 36 45 54 63 72 81 90
Program 10: WAP in python to display the sum of a range of user entered numbers.
Code:
sn=int(input("Enter starting value of range="))
ln=int(input("Enter last value of range="))
s=0
for i in range(sn,ln+1):
s=s+i
print("Sum=",s)
Output:
Enter starting value of range=1
Enter last value of range=10
Sum= 55
Program 11: WAP in python to display the product of a range of user entered numbers.
Code:
sn=int(input("Enter starting value of range="))
ln=int(input("Enter last value of range="))
p=1
for i in range(sn,ln+1):
p=p*i
print("Product=",p)
Output:
Enter starting value of range=1
Enter last value of range=5
Product= 120
Program 12: WAP in python to display Fibonacci series up to user entered terms.
Code:
n=int(input("Enter how many terms you want to display"))
a=0
b=1
print(a, b, end=" ")
for i in range(3,n+1):
c=a+b
print(c, end=" ")
a=b
b=c
Output:
Enter how many terms you want to display10
0 1 1 2 3 5 8 13 21 34
6
Program 13: WAP in python to check whether a user entered number is prime number or not.
Code:
n=int(input("Enter a number"))
status=False
for i in range(2,n//2+1):
if n%i==0:
status=True
break
if status==True:
print("not prime")
else:
print("prime")
Output:
Enter a number9
Entered number 9 is not prime
Enter a number11
Entered number 11 is prime
Program 14: WAP in python to display prime numbers between the given number of range.
Code:
sn=int(input("Enter Starting number of range="))
ln=int(input("Enter last number of range="))
for n in range(sn,ln+1):
for i in range(2,n//2+1):
if n%i==0:
break
else:
if n==1:
pass
else:
print(n)
Output:
Enter Starting number of range=1
Enter last number of range=10
2
3
5
7
7
Program 15: WAP in python to display the reverse of a user entered integer number.
Code:
n=int(input("Enter a number"))
no=n
s=0
while n>0:
r=n%10
s=s*10+r
n=n//10
print("The reverse of a number",no,"is", s)
Output:
Enter a number845
The reverse of a number 845 is 548
Program 16: WAP in python to check whether a user entered number is a palindrome number or not.
Code:
n=int(input("Enter a number"))
no=n
s=0
while n>0:
r=n%10
s=s*10+r
n=n//10
if no==s:
print("This is a Palindrome Number")
else:
print("This is not a Palindrome Number")
Output:
Enter a number789
This is not a Palindrome Number
Enter a number787
This is a Palindrome Number
Code:
for i in range(1,6):
for j in range(1,i+1):
print("*", end=" ")
print()
8
Program 18: WAP in python to print the following pattern:
1
12
123
1234
12345
Code:
for i in range(6):
print()
for j in range(1,i+1):
print(j,end=" ")
Code:
for i in range(5):
print()
for j in range(5-i,0,-1):
print(j,end=" ")
Code:
for i in range(6):
print()
for j in range(65,65+i):
print(chr(j),end=" ")
Program 21: WAP in python to print the sum of the following series:
1+2+3+4+5+6…………………………………
Code:
s=0
n=int(input("Enter number of terms upto which you want to calculate sum="))
for i in range(1,n+1):
s=s+i
print("The sum of the given series upto",n,"terms=",s)
9
Output:
Enter number of terms upto which you want to calculate sum=5
The sum of the given series upto 5 terms= 15
Program 22: WAP in python to print the sum of the following series:
1+(1/2)+(1/3)+(1/4)+(1/5)+(1/6)…………………………………
Code:
s=0
n=int(input("Enter number of terms upto which you want to calculate sum="))
for i in range(1,n+1):
s=s+(1/i)
print("The sum of the given series upto",n,"terms=",s)
Output:
Enter number of terms upto which you want to calculate sum=5
The sum of the given series upto 5 terms= 2.283333333333333
Program 23: WAP in python to print the sum of the following series:
1+(1/!2)+(1/!3)+(1/!4)+(1/!5)+(1/!6)……………………………
Code:
def fact(x):
f=1
for k in range(1,x+1):
f=f*k
return f
s=0
n=int(input("Enter number of terms upto which you want to calculate sum="))
for i in range(1,n+1):
s=s+(1/fact(i))
print("The sum of the given series upto",n,"terms=",s)
Output:
Program 24: WAP in python to input a list of numbers and display the largest value from it.
Code:
l=eval(input("Enter a list of integer elements="))
size=len(l)
largest=0
for i in range(0,size):
if l[i]>largest:
largest=l[i]
print("The largest among all list elements=",largest)
10
Output:
Enter a list of integer elements=[50,1,70,-9,100,45,30]
The largest among all list elements= 100
Program 25: WAP in python to input a list of numbers and display the second largest value from it.
Code:
import sys
l=eval(input("Enter a list of integer elements="))
size=len(l)
largest=slargest=-sys.maxsize-1
for i in range(0,size):
if l[i]>largest:
slargest=largest
largest=l[i]
elif l[i]>slargest:
slargest=l[i]
print("The second largest number among all list elements=",slargest)
Output:
Enter a list of integer elements=[70,-50,90,40,80,40,110,75]
The second largest number among all list elements= 90
Program 26: WAP in python to input a list of numbers and display the position of user entered number.
Code:
L=eval(input("Enter a list of integer elements="))
svalue=eval(input("Enter a searched element="))
size=len(L)
found=0
for i in range(0,size):
if L[i]==svalue:
found=1
break
if found==1:
print("The searched element",svalue,"is found at", i+1,"position.")
else:
print("The searched element",svalue,"is not found")
Output:
Enter a list of integer elements=[10,60,3,70,90,52]
Enter a searched element=90
The searched element 90 is found at 5 position.
11
Program 27: WAP in python to input a list of numbers and display the sum & average of list elements.
Code:
l=eval(input("Enter a list of integer elements="))
size=len(l)
sum=0
for i in range(0,size):
sum=sum+l[i]
print("The sum of all list elements=",sum)
print("The average of all list elements=",sum/size)
Output:
Enter a list of integer elements=[10,20,30,40,50]
The sum of all list elements= 150
The average of all list elements= 30.0
Program 28: WAP in python to input a list of numbers and display the sum of all odd values.
Code:
l=eval(input("Enter a list of integer elements="))
size=len(l)
sum=0
for i in range(0,size):
if l[i]%2!=0:
sum=sum+l[i]
print("The sum of all odd list elements=",sum)
Output:
Enter a list of integer elements=[15,80,33,40,72]
The sum of all odd list elements= 48
Program 29: WAP in python to input names of employees and their salaries, store them in a dictionary
and display this dictionary.
Code:
employee={}
n=int(input("Enter number of employee="))
for i in range(n):
ename=input("Enter employee name=")
esalary=int(input("Enter employee salary="))
employee[ename]=esalary
Output:
Enter number of employee=5
Enter employee name=rahul
Enter employee salary=5000
Enter employee name=keshav
12
Enter employee salary=4300
Enter employee name=mehul
Enter employee salary=9000
Enter employee name=ramesh
Enter employee salary=1500
Enter employee name=asif
Enter employee salary=6200
The employee details are:
{'rahul': 5000, 'keshav': 4300, 'mehul': 9000, 'ramesh': 1500, 'asif': 6200}
13
MYSQL QUERIES
Q1: Write SQL command to Create a database KVLUMDING.
SQL Command:
CREATE DATABASE KVLUMDING;
Q2: Write SQL command to use database KVLUMDING.
SQL Command:
USE KVLUMDING;
Q3: Write SQL command to Create a table STUDENT as per following specification:
14
SQL Command:
INSERT INTO STUDENT VALUES(1001,'XII','A','M','AMIT SINGH','2005-10-25',85.5);
INSERT INTO STUDENT VALUES(1008,'XII','B','F','RIYA CHANDAK','2006-10-05',95);
INSERT INTO STUDENT VALUES(1005,'XI','A','F','KRITI SENAN','2007-02-10',78);
INSERT INTO STUDENT VALUES(1009,'XII','A','M','ARPAN RAO','2005-03-11',90.5);
INSERT INTO STUDENT VALUES(1019,'XI','B','M','SANJAY CHAUHAN','2007-07-21',27);
INSERT INTO STUDENT VALUES(1050,'XI','A','M','SUDHIR KUMAR','2007-06-26',69);
INSERT INTO STUDENT VALUES(1021,'XII','B','F','SUMAN KALSHI','2006-07-07',84);
INSERT INTO STUDENT VALUES(2016,'IX','A','M','SALMAN ALI','2008-08-21',92.5);
INSERT INTO STUDENT VALUES(2089,'VIII','A','M','ARIJIT SEN',NULL,32);
INSERT INTO STUDENT VALUES(2000,'X','B','F','RIYA KUMARI','2008-06-17',83.5);
Q7: Write SQL command to display student id, student name, student gender and student marks of all
students.
SQL Command:
SELECT ID, NAME, GENDER, MARKS FROM STUDENT;
Output:
Q8: Write SQL command to display details of all the students who worn between 01/01/2006 to
31/01/2007.
15
SQL Command:
SELECT * FROM STUDENT WHERE DOB BETWEEN '2006-01-01' AND '2007-01-31';
Output:
Q9: Write SQL command to display details of all the students whose names are started with ‘s’
character.
SQL Command:
SELECT * FROM STUDENT WHERE NAME LIKE 'S%';
Q10: Write SQL command to display details of all the students whose marks percentage is less than 33.
SQL Command:
SELECT * FROM STUDENT WHERE MARKS<33;
Output:
Q11: Write SQL command to display students name and percentage of marks of class XII and section B.
SQL Command:
SELECT NAME, MARKS FROM STUDENT WHERE SCLASS='XII' AND SECTION='B';
Output:
Q12: Write SQL command to display a list of students from VIII, IX and X classes.
SQL Command:
SELECT * FROM STUDENT WHERE SCLASS IN('VIII', 'IX', 'X');
Output:
16
Q13: Write SQL command to display id, name, dob, marks of male students in ascending order of their
names.
SQL Command:
SELECT ID, NAME, DOB, MARKS FROM STUDENT WHERE GENDER='M' ORDER BY NAME ASC;
Output:
Q14: Write SQL command to display id, name, dob, marks of female students in descending order of
their marks.
SQL Command:
SELECT ID, NAME, DOB, MARKS FROM STUDENT WHERE GENDER='F' ORDER BY MARKS DESC;
Output:
Q16: Write SQL command to display the details of the students whose data of birth is null.
SQL Command:
SELECT * FROM STUDENT WHERE DOB IS NULL;
Output:
Q17: Write SQL command to change the date of birth by 20/10/2000 for those students whose data of
birth is null.
17
SQL Command:
UPDATE STUDENT SET DOB=’2000-10-20’ WHERE DOB IS NULL;
Q18: Write SQL command to change the marks of all the students by 2.
SQL Command:
UPDATE STUDENT SET MARKS=MARKS+2;
Q19: Write SQL command to delete the details of those students whose class is XII.
SQL Command:
DELETE FROM STUDENT WHERE SCLASS=’XII’;
Q20: Write SQL command to delete all the details of the students.
SQL Command:
DELETE FROM STUDENT;
Q22: Write SQL command to add a new column in the student table with the following specifications:
Column name: address
Data type: varchar
Size: 25
SQL Command:
ALTER TABLE STUDENT ADD COLUMN ADDRESS VARCHAR(25);
Q23: Write SQL command to modify/change the old specification of address column with new
specifications in the student table.
Column name: address
Data type: char
Size: 30
SQL Command:
ALTER TABLE STUDENT MODIFY COLUMN ADDRESS CHAR(30);
Q24: Write SQL command to modify/change the name of old column name address with new column
name stuaddress in the student table.
SQL Command:
ALTER TABLE STUDENT CHANGE COLUMN ADDRESS STUADDRESS VARCHAR(25);
Q25: Write SQL command to delete address column from the student table.
SQL Command:
ALTER TABLE STUDENT DROP COLUMN ADDRESS;
18