I.P. Practical File

Download as pdf or txt
Download as pdf or txt
You are on page 1of 42

Practical

File
NAME: __________________________
JANMESH SINGH BALI

CLASS: _________________
12

SECTION:_______________
A

ROLL. NO.: _____________


9

SUBJECT: INFORMATICS PRACTICES

Internal Examiner External Examiner


ACKNOWLEDGEMENT
I am thankful to my computer teacher Mr. Vikas Sawhney
who helped and guided me while making this practical file.
I would also like to thank I.T department, Heritage school
which helped and gave me time for the completion of my
practical file.
INDEX
S.NO TITLE PG.NO.
1. Write a program to generate a series of the first 6
10 numbers.
2. Write a program to generate a series using a
dictionary to represent month number and 7
month names.
3. Write a program to generate a series of marks
of 10 students. Give grace marks up to 5 of 8
those who are having <33 marks and print the
new list of the marks.
4. Write a program to generate a series of these
numbers: 33,55,65,29,19,23. Find the sum of 9
those values which are ending with 3 or 5.
5. Write a program to generate a series of 10 10
numbers with scalar value 33.
6. Write a program to generate a series with these
numbers: 21,51,71,31,12. Exchange all these
values of series by shifting each of them to the 11
next position and by shifting the last value to the
first index.
7. Write a program to generate a series of float
numbers from 21.0 to 30.0 with an increment 12
of 1.5 each.
8. Write a program to generate a series of 5
elements of multiples of 7 starting with 35 with 13
index multiply by 3.
9. Write a program to generate a series of 10
numbers starting with 41 and with the
increment of 3. Now add 7 all odd values and 14
subtract 3 in even values. Reprint the updated
series.
10 Write a program to generate s1 with prime
. numbers between 1 to 25 and s2 with factorial 15
numbers between 1 to 25.
11 Write a program to generate a series with these
. numbers: 21, 51, 71, 31, 12. Exchange all these
values of series by shifting each of them one to 16
one position before and by shifting the first
value to last position.
12 Write a program to generate a series with
. indexes starting with 1. Reindex the series with 17
odd values starting with 4.
13 Write a program to generate a series and print 18
. the bottom 3 elements using the tail function.
14 Write a program to generate a series and print 19
. the top 3 elements using the head function.
15 Write a program to generate a series of 10
. numbers. Change the value of all the elements 20
those values are multiples of 4.
16 Plot following data on line chart: 21-22
.
17 Observe the given data for monthly views of one
. of the youtube channels for 6 months. Plot them 23-24
on the line chart.
18 Consider the following data of a medical store 25-26
. and subplot sanitizer data and handwash data.
19 Display following bowling figures through bar 27
. chart:
20 Write a program to plot a range from 1 to 30
28
. with step value 4. Use following algebraic
expression to show data.
21 SQL Commands:
. Create the database loans. 29
Use database loans.
Create table loan_accounts and insert tuples in
it.
Display details of all the loans.
Display the accno, cust_name and loan_amount
of all the loans.
Display details of all the loans with less than 40
installments.
Display the accno and loan_amount of all the
loans started before 01-04-2009.
Display the int_rate of all the loans started after
01-04-2009.
Display the details of all the loans whose rate of
interest is null.
Display the amount of various loans from the
table loan_accounts. A loan amount should
appear only once.
Display the cust_name and loan_amount for all
the loans which do not have number of
installments 36.
Display the cust_name and loan_amount for all
the loans for which the loan amount is less than
500000 or int_rate is more than 12.
Display the details of all the loans whose rate of
interest is in the range 11% to 12%.
Display the cust_name and loan_amount for all
the loans for which the number of installments
are 24, 36, or 48.
Display the details of all the loans whose
loan_amount is in the range 400000 to
500000.
Display the accno, cust_name, loan_amount for
all the loans for which the cust_name ends with
“Sharma”.
Display the accno, cust_name, and
loan_amount for all the loans for which the
cust_name contains ‘a’ as the second last
character.
Display the details of all the loans in the
ascending order of their loan_amount.
Display the details of all the loans in the
descending order of their start_date.
Put the interest rate 11.50% for all the loans for
which interest rate is null.
For each loan replace interest with
(loan_amount * int_rate*installments)/12*100.
Delete the records of all the loans of “k.p. jain”.
Add another category of type char(1) in the
loan_accounts table.
Find the output of the following :
Write the output produce by the following SQL
commands :
1. Write a program to generate a series of the first 10
numbers.

Solution:

import pandas as pd
def Ser_1to10():
s = pd.Series(range(1,11))
print(s)
Ser_1to10()

OUTPUT:

6|PAGE
2. Write a program to generate a series using a
dictionary to represent month number and month
names.

Solution:

import pandas as pd
def Ser_dic():
di={1:'January',2:'February',3:'March',4:'April',
5:'May',6:'June',7:'July',8:'August',9:'September',
10:'October',11:'November',12:'December'}
s = pd.Series(di)
print(s)
Ser_dic()

OUTPUT:

7|PAGE
3. Write a program to generate a series of marks of 10
students. Give grace marks up to 5 of those who are
having <33 marks and print the new list of the marks.
Solution:

import pandas as pd
def Ser_stumarks():
std_marks = []
for i in range(1,11):
m = int(input("Enter the marks:"))
std_marks.append(m)

s=pd.Series(index=range(1201,1211),data=std_marks)
s[s<33]=s+5
print("New List is:")
print(s[s>=33])
Ser_stumarks()

OUTPUT:

8|PAGE
4. Write a program to generate a series of these
numbers: 33,55,65,29,19,23. Find the sum of those
values which are ending with 3 or 5.

Solution:

import pandas as pd
list=[33,55,65,29,19,23]
ser=pd.Series(list)
val_sum=0
sum5=sum(ser[ser % 10==5])
sum3=sum(ser[ser % 10==3])
print(sum3+sum5)

OUTPUT:

9|PAGE
5. Write a program to generate a series of 10 numbers
with scalar value 33.

Solution:

import pandas as pd
print(pd.Series(33,range(1,11)))

OUTPUT:

10|PAGE
6. Write a program to generate a series with these
numbers: 21, 51, 71, 31, 12. Exchange all these
values of series by shifting each of them to the next
position and by shifting the last value to the first
index.

Solution:

import pandas as pd
import numpy as np
s=pd.Series([21,51,71,31,12])
print(pd.Series(np.roll(s.values,1),index=s.index))

OUTPUT:

11|PAGE
7. Write a program to generate a series of float numbers
from 21.0 to 30.0 with an increment of 1.5 each.

Solution:

import pandas as pd
import numpy as np
def Ser_1to10():
n=np.arange(21,32,1.5)
s=pd.Series(n)
print(s)
Ser_1to10()

OUTPUT:

12|PAGE
8. Write a program to generate a series of 5 elements of
multiples of 7 starting with 35 with index multiply by
3.

Solution:

import pandas as pd
import numpy as np
def Ser_mul7():
a = 35
n = np.arange(a,a*2,7)
s = pd.Series(index=n*3,data=n)
print(s)
Ser_mul7()

OUTPUT:

13|PAGE
9. Write a program to generate a series of 10 numbers
starting with 41 and with the increment of 3. Now
add 7 all odd values and subtract 3 in even values.
Reprint the updated series.

Solution:

import pandas as pd
s=pd.Series(range(41,71,3))
s[s % 2!=0]=s+7
s[s % 2==0]=s-3
print(s)

OUTPUT:

14|PAGE
10. Write a program to generate s1 with prime numbers
between 1 to 25 and s2 with factorial numbers
between 1 to 25.

Solution:

import pandas as pd
import math
s1=pd.Series(x for x in range(1,25)
if all(x % y!=0 for y in range(2,x)))
s2=pd.Series([math.factorial(n) for n in range(25)])
print(s1)
print(s2)

OUTPUT:

15|PAGE
11. Write a program to generate a series with these
numbers: 21, 51, 71, 31, 12. Exchange all these
values of series by shifting each of them one to one
position before and by shifting the first value to last
position.

Solution:

import pandas as pd
import numpy as np
s=pd.Series([21,51,71,31,12])
print(pd.Series(np.roll(s.values,-1),index=s.index))

OUTPUT:

16|PAGE
12. Write a program to generate a series with indexes
starting with 1. Reindex the series with odd values
starting with 4.

Solution:

import pandas as pd
ser_length=int(input(“Enter the length of the
series:”))
data=[]
for i in range(ser_length):
val=int(input(“Enter a val:”))
data.append(val)
ser=pd.Series(data,range(1,ser_length+1))
print(ser)

OUTPUT:

17|PAGE
13. Write a program to generate a series and print the
bottom 3 elements using the tail function.

Solution:

import pandas as pd
ser_length=int(input(“Enter the length of the
series:”))
data=[]
for i in range(ser_length):
val=int(input(“Enter a val:”))
data.append(val)
ser=pd.Series(data)
print(ser.tail(3))

OUTPUT:

18|PAGE
14. Write a program to generate a series and print the top
3 elements using the head function.

Solution:

import pandas as pd
ser_length=int(input(“Enter the length of the series:”))
data=[]
for i in range(ser_length):
val=int(input(“Enter a val:”))
data.append(val)
ser=pd.Series(data)
print(ser.head(3))

OUTPUT:

19|PAGE
15. Write a program to generate a series of 10 numbers.
Change the value of all the elements those values are
multiples of 4.

Solution:

import pandas as pd
numbers=[]
for i in range(1,11):
val=int(input(“Enter a number:”))
numbers.append(val)
ser=pd.Series(numbers)
ser[ser % 4==0]=21
print(ser)

OUTPUT:

20|PAGE
16. Plot following data on line chart:

Day Monday Tuesday Wednesday Thursday Friday


Income 510 350 475 580 600

1. Write a title for the chart “The Weekly Income


Report”.
2. Write the appropriate titles of both the axes.
3. Write code to Display legends.
4. Display red color for the line.
5. Use the line style – dashed
6. Display diamond style markers on data points

Solution:

import matplotlib.pyplot as pp

day=[‘Monday’,‘Tuesday’,‘Wednesday’,‘Thursday’,‘Friday’]
inc=[510,350,475,580,600]
pp.plot(day,inc,label=‘Income’,color=‘r’,linestyle=‘dashed’,
marker=‘D’)
pp.title(“The Weekly Income Report”)
pp.xlabel(“Days”)
pp.ylabel(“Income”)
pp.legend()
pp.show()

21|PAGE
OUTPUT:

22|PAGE
17. Observe the given data for monthly views of one of
the youtube channels for 6 months. Plot them on the
line chart.
Month January February March April May June

Views 2500 2100 1700 3500 3000 3800

Apply following customizations to the chart:


1. Give the title for the chart – “Youtube Stats”
2. Use the “Month” label for X-Axis and “Views” for
Y-Axis.
3. Display legends.
4. Use dashed lines with the width 5 point.
5. Use red color for the line.
6. Use dot marker with blue edge color and black fill
color.

Solution:
import matplotlib.pyplot as pp
mon=[‘January’,’February’,’March’,’April’,’May’,’June’]
views=[2500,2100,1700,3500,3000,3800]
pp.plot(mon,views,label=‘Views State’,color=‘r’,
linestyle=‘dashed’,linewidth=4,marker=‘o’,
markerfacecolor=‘k’,markeredgecolor=‘b’)

23|PAGE
pp.title(“Youtube Stats”)
pp.xlabel(“Months”)
pp.ylabel(“Views”)
pp.legend()
pp.show()

OUTPUT:

24|PAGE
18. Consider the following data of a medical store and
subplot sanitizer data and handwash data.
Months Mask Sanitizer Handwash
March 1500 4400 6500
April 3500 4500 5000
May 6500 5500 5800
June 6700 6000 6300
July 6000 5600 6200
August 6800 6300 4500

Solution:

import matplotlib.pyplot as pp
mon=[‘March’,’April’,’May’,’June’,’July’,’August’]
san=[4400,4500,5500,6000,5600,6300]
hw=[6500,5000,5800,6300,6200,4500]
pp.subplot(2,1,1)
pp.plot(mon,san,label=‘Sanitizer’,color=‘b’,linestyle=‘dashed’
,linewidth=4,marker=‘o’,markerfacecolor=‘k’,
markeredgecolor=‘r’)
pp.title(“Fitwell Medical Store”)
pp.legend()
pp.subplot(2,1,2)
pp.plot(mon,hw,label=‘Handwash’,color=‘r’,linestyle=‘dashed’
,linewidth=4,marker=‘v’,markerfacecolor=‘k’,
markeredgecolor=‘b’)
pp.xlabel(“Months”)
pp.ylabel(“Covid Protections”)
pp.legend()
pp.show()

25|PAGE
OUTPUT:

26|PAGE
19. Display following bowling figures through bar
chart:

Overs Runs
1 6
2 8
3 10
4 15

Solution:
import matplotlib.pyplot as pp
overs=[1,2,3,4]
runs=[6,8,10,15]
p.bar(overs,runs,color=‘m’)
. pp.xlabel(‘Overs’)
pp.ylabel(‘Runs’)
pp.title(‘Bowling Spell Analysis’)
pp.show()

OUTPUT:

27|PAGE
20. Write a program to plot a range from 1 to 30 with
step value 4. Use following algebraic expression to
show data.
y = 5*x+2
Solution:

import matplotlib.pyplot as pp
import numpy as np
x=np.arange(1,30,4)
y=5*x+2
pp.plot(x,y)
pp.show()

OUTPUT:

28|PAGE
SQL COMMANDS…

1. Create the database loans.

2. Use database loans.

Solution:

3. Create table loan_accounts and insert tuples in it.


Solution:

29|PAGE
4. Display details of all the loans.

Solution:

5. Display the accno, cust_name and loan_amount of


all the loans.

Solution:

30|PAGE
6. Display details of all the loans with less than 40
installments.

Solution:

7. Display the accno and loan_amount of all the loans


started before 01-04-2009.

Solution:

31|PAGE
8. Display the int_rate of all the loans started after
01-04-2009.

Solution:

9. Display the details of all the loans whose rate of


interest is null.

Solution:

32|PAGE
10. Display the amount of various loans from the table
loan_accounts. A loan amount should appear only
once.

Solution:

11. Display the cust_name and loan_amount for all the


loans which do not have number of installments 36.

Solution:

33|PAGE
12. Display the cust_name and loan_amount for all
the loans for which the loan amount is less than
500000 or int_rate is more than 12.

Solution:

13. Display the details of all the loans whose rate of


interest is in the range 11% to 12%.

Solution:

34|PAGE
14. Display the cust_name and loan_amount for all the
loans for which the number of installments are 24,
36, or 48.

Solution:

15. Display the details of all the loans whose


loan_amount is in the range 400000 to 500000.

Solution:

35|PAGE
16. Display the accno, cust_name, loan_amount for all
the loans for which the cust_name ends with
“Sharma”.

Solution:

17. Display the accno, cust_name, and loan_amount


for all the loans for which the cust_name contains ‘a’
as the second last character.

Solution:

36|PAGE
18. Display the details of all the loans in the ascending
order of their loan_amount.

Solution:

19. Display the details of all the loans in the


descending order of their start_date.
Solution:

37|PAGE
20. Put the interest rate 11.50% for all the loans for
which interest rate is null.

Solution:

21. For each loan replace interest with (loan_amount *


int_rate*installments)/12*100.

Solution:

22. Delete the records of all the loans of “k.p. jain”.

Solution:

38|PAGE
23. Add another category of type char(1) in the
loan_accounts table.
Solution:

24. Find the output of the following :


a. Select cust_name , length(cust_name), lcase(cust_name),
Ucase(cust_name) from loan_accounts where int_rate <11.00;
Solution:

b. Select left(cust_name,3), right(cust_name,3),


substr(cust_name,1,3) from loan_accounts where int_rate >
10.00;
Solution:

39|PAGE
c. Select dayname(start_date) from loan_accounts;

Solution:

d. Select round(int_rate*110/100,2) from loan_accounts where


int_rate >10;

Solution:

25. Write the output produce by the following SQL


commands :
a. Select pow(4,3), pow(3,4);

Solution:

40|PAGE
b. Select round(543.5694,2) , round(543.5694),
round(543.5634,-1);

Solution:

c. Select truncate(543.5694,2), truncate(543.5694,-1);

Solution:

d. Select concat(“samandeep”, “ singh”) “full name”;

Solution:

41|PAGE
e. Select year(curdate()), month(curdate()), day(curdate());

Solution:

f. Select instr(“Unicode”, “co”), instr(“Unicode”, “ cd”);

Solution:

g. Select mid(“informatics”,3,4),substr(“practices”,3);

Solution:

42|PAGE

You might also like