Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 23

INFORMATICS PRACTICES

PRACTICAL FILE

NEHRU WORLD SCHOOL

REPORTED TO: Ms. Richa Rana

REPORTED BY: ARYAN GAUR | XII PCM

ROLL NO: 88888888

Page | 1
CERTIFICATE

This is to certify that Aryan gaur of class 12th


PCM has successfully completed the
practical file for Informatics practices. Under
the guidance of Ms. Richa Rana for the year
2023-24

Ms. Richa Rana


Date:
(PGT, INFORMATICS PRACTICES)
Class 12th PCM
N.W.S. GZB

Page | 2
PYTHON

Page | 3
1. import pandas as pd
2. import numpy as np

3. #QUESTION 5 (a)
4. EngAlph=pd.Series(['A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'])
5. EngAlph
6. 0 A
7. 1 B
8. 2 C
9. 3 D
10.4 E
11.5 F
12.6 G
13.7 H
14.8 I
15.9 J
16.10 K
17.11 L
18.12 M
19.13 N
20.14 O
21.15 P
22.16 Q
23.17 R
24.18 S

Page | 4
25.19 T
26.20 U
27.21 V
28.22 W
29.23 X
30.24 Y
31.25 Z
32.dtype: object

33. #(b)
34.Vowels=pd.Series([0,0,0,0,0],index=['a','e','i','o','u'])
35.Vowels
36.a 0
37.e 0
38.i 0
39.o 0
40.u 0
41.dtype: int64
42.Vowels.empty
43.False

44. #(c)
45.d1={'Akshat':1,'Aryan':2,'Avi':3,'Ayush':4,'Vaibhav':5}
46.Friends=pd.Series(d1)
47.Friends
48.Akshat 1
49.Aryan 2
50.Avi 3
51.Ayush 4
52.Vaibhav 5
53.dtype: int64

54. #(d)
55.MtSeries=pd.Series(dtype=int)
56.MtSeries
57.Series([], dtype: int32)
58.MtSeries.empty
59.True

60. #(e)
61.n1=np.array([31,28,31,30,31,30,31,31,30,31,30,31])
62.MonthDays=pd.Series(n1,index=[1,2,3,4,5,6,7,8,9,10,11,12])
63.MonthDays
64.1 31
65.2 28
66.3 31

Page | 5
67.4 30
68.5 31
69.6 30
70.7 31
71.8 31
72.9 30
73.10 31
74.11 30
75.12 31
76.dtype: int32

77. #QUESTION 6(a)


78.Vowels=pd.Series([10,10,10,10,10],index=['a','e','i','o','u'])
79.Vowels
80.a 10
81.e 10
82.i 10
83.o 10
84.u 10
85.dtype: int64

86. #(b)
87.Vowels/2
88.a 5.0
89.e 5.0
90.i 5.0
91.o 5.0
92.u 5.0
93.dtype: float64

94. #(c)
95.Vowels1=pd.Series([2,5,6,3,8],index=['a','e','i','o','u'])
96.Vowels1
97.a 2
98.e 5
99.i 6
100. o 3
101. u 8
102. dtype: int64

103. #(d)
104. Vowels3=Vowels+Vowels1
105. Vowels3
106. a 12
107. e 15
108. i 16

Page | 6
109. o 13
110. u 18
111. dtype: int64

112. #(e)
113. Vowels-Vowels1
114. a 8
115. e 5
116. i 4
117. o 7
118. u 2
119. dtype: int64
120. Vowels/Vowels1
121. a 5.000000
122. e 2.000000
123. i 1.666667
124. o 3.333333
125. u 1.250000
126. dtype: float64
127. Vowels*Vowels1
128. a 20
129. e 50
130. i 60
131. o 30
132. u 80
133. dtype: int64

134. #(f)
135. Vowels1.index=['A','E','I','O','U']
136. Vowels1
137. A 2
138. E 5
139. I 6
140. O 3
141. U 8
142. dtype: int64

Page | 7
1. import pandas as pd

2. #QUESTION 11
3. d1={2014:[100.5,150.8,200.9,30000,40000],2015:
[12000,18000,22000,30000,45000],2016:
[20000,50000,70000,100000,125000],2017:[50000,60000,70000,80000,90000]}
4. Sales=pd.DataFrame(d1,index=['Madhu','Kusum','Kinshuk','Ankit','Shruti'])
5. d2={2018:[160000,110000,500000,340000,900000]}
6. Sales2=pd.DataFrame(d2,index=['Madhu','Kusum','Kinshuk','Ankit','Shruti'])
7. #(a)
8. Sales=Sales.append(Sales2)
9. Sales
10. 2014 2015 2016 2017 2018
11.Madhu 100.5 12000.0 20000.0 50000.0 NaN
12.Kusum 150.8 18000.0 50000.0 60000.0 NaN
13.Kinshuk 200.9 22000.0 70000.0 70000.0 NaN
14.Ankit 30000.0 30000.0 100000.0 80000.0 NaN
15.Shruti 40000.0 45000.0 125000.0 90000.0 NaN
16.Madhu NaN NaN NaN NaN 160000.0
17.Kusum NaN NaN NaN NaN 110000.0
18.Kinshuk NaN NaN NaN NaN 500000.0
19.Ankit NaN NaN NaN NaN 340000.0
20.Shruti NaN NaN NaN NaN 900000.0

21. #(b)
22.Sales.T
23. Madhu Kusum Kinshuk ... Kinshuk Ankit Shruti
24.2014 100.5 150.8 200.9 ... NaN NaN NaN
25.2015 12000.0 18000.0 22000.0 ... NaN NaN NaN
26.2016 20000.0 50000.0 70000.0 ... NaN NaN NaN
27.2017 50000.0 60000.0 70000.0 ... NaN NaN NaN
28.2018 NaN NaN NaN ... 500000.0 340000.0 900000.0
29.
30.[5 rows x 10 columns]

31. #(c)
32.Sales[2017]
33.Madhu 50000.0
34.Kusum 60000.0
35.Kinshuk 70000.0
36.Ankit 80000.0
37.Shruti 90000.0
38.Madhu NaN
39.Kusum NaN
40.Kinshuk NaN
41.Ankit NaN

Page | 8
42.Shruti NaN
43.Name: 2017, dtype: float64

44. #(d)
45.Sales[2017]['Madhu']
46.Madhu 50000.0
47.Madhu NaN
48.Name: 2017, dtype: float64
49.Sales[2018]['Madhu']
50.Madhu NaN
51.Madhu 160000.0
52.Name: 2018, dtype: float64
53.Sales[2017]['Ankit']
54.Ankit 80000.0
55.Ankit NaN
56.Name: 2017, dtype: float64
57.KeyboardInterrupt
58.Sales[2018]['Ankit']
59.Ankit NaN
60.Ankit 340000.0
61.Name: 2018, dtype: float64

62. #(e)
63.Sales[2017]['Shruti']
64.Shruti 90000.0
65.Shruti NaN
66.Name: 2017, dtype: float64

67. #(f)
68.Sales2=pd.DataFrame(d2,index=['Madhu','Kusum','Kinshuk','Ankit','Shruti'])
69.Sales=pd.DataFrame(d1,index=['Madhu','Kusum','Kinshuk','Ankit','Shruti'])
70.Sales3=Sales.T.append(Sales2.T)
71.Sales3['Sumeet']=[196.2,37800,52000,78438,38852]
72.Sales3
73. Madhu Kusum Kinshuk Ankit Shruti Sumeet
74.2014 100.5 150.8 200.9 30000.0 40000.0 196.2
75.2015 12000.0 18000.0 22000.0 30000.0 45000.0 37800.0
76.2016 20000.0 50000.0 70000.0 100000.0 125000.0 52000.0
77.2017 50000.0 60000.0 70000.0 80000.0 90000.0 78438.0
78.2018 160000.0 110000.0 500000.0 340000.0 900000.0 38852.0

79. #(g)
80.del Sales[2014]
81.Sales
82. 2015 2016 2017
83.Madhu 12000 20000 50000

Page | 9
84.Kusum 18000 50000 60000
85.Kinshuk 22000 70000 70000
86.Ankit 30000 100000 80000
87.Shruti 45000 125000 90000

88. #(h)
89.Sales=Sales.drop('Kinshuk', axis=0)
90.Sales
91. 2015 2016 2017
92.Madhu 12000 20000 50000
93.Kusum 18000 50000 60000
94.Ankit 30000 100000 80000
95.Shruti 45000 125000 90000

96. #(i)
97.Sales.rename({'Ankit':'vivaan','Madhu':'Shailesh'}, axis='index')
98. 2015 2016 2017
99.Shailesh 12000 20000 50000
100. Kusum 18000 50000 60000
101. vivaan 30000 100000 80000
102. Shruti 45000 125000 90000

103. #(j)
104. Sales3.loc[2018]['Shailesh']= 100000
105. Sales3
106. Madhu Kusum Kinshuk Ankit Shruti Sumeet
107. 2014 100.5 150.8 200.9 30000.0 40000.0 196.2
108. 2015 12000.0 18000.0 22000.0 30000.0 45000.0 37800.0
109. 2016 20000.0 50000.0 70000.0 100000.0 125000.0 52000.0
110. 2017 50000.0 60000.0 70000.0 80000.0 90000.0 78438.0
111. 2018 160000.0 110000.0 500000.0 340000.0 900000.0 38852.0
112. Sales3.T
113. 2014 2015 2016 2017 2018
114. Madhu 100.5 12000.0 20000.0 50000.0 160000.0
115. Kusum 150.8 18000.0 50000.0 60000.0 110000.0
116. Kinshuk 200.9 22000.0 70000.0 70000.0 500000.0
117. Ankit 30000.0 30000.0 100000.0 80000.0 340000.0
118. Shruti 40000.0 45000.0 125000.0 90000.0 900000.0
119. Sumeet 196.2 37800.0 52000.0 78438.0 38852.0

120. #(k)
121. Sales.to_csv('salesq.csv', index = True)

122. #(l)
123. salesr=pd.read_csv('salesq.csv',names=['2014', '2015', '2016',
'2017'])
124. salesr.index=['Shailesh','Kusum','Kinshuk','vivaan','shruti']

Page | 10
125. salesr
126. 2014 2015 2016 2017
127. Shailesh NaN 2015 2016 2017
128. Kusum Madhu 12000 20000 50000
129. Kinshuk Kusum 18000 50000 60000
130. vivaan Ankit 30000 100000 80000
131. shruti Shruti 45000 125000 90000
132.

CODE:

Page | 11
CSV FILE USED:

Page | 12
OUTPUT:

Page | 13
CODE:

OUTPUT:

Page | 14
CSV
FILE

USED:

CODE:

Page | 15
OUTPUT:

CODE:

Page | 16
OUTPUT :

Page | 17
CODE:

OUTPUT:

OR

Page | 18
OUTPUT:

OUTPUT:

Page | 19
MYSQL

Page | 20
Page | 21
Q- Consider table named “Product:
Create the table Product with appropriate data types and constraints. Write
the output(s) produced by executing the following queries on the basis of the
information given above in the table Product:
i) SELECT PName, Average (UPrice) FROM Product GROUP BY
Pname; (ii) SELECT DISTINCT Manufacturer FROM Product;
iii.SELECT COUNT(DISTINCT PName) FROM Notes Product;
iv. SELECT PName, MAX(UPrice), MIN(UPrice) FROM Product GROUP
BY PName;

Page | 22
Page | 23

You might also like