0% found this document useful (0 votes)
19 views23 pages

Class 12 Informatics Practices File

The document contains code in Python to perform operations on pandas Series and DataFrames. Various operations like indexing, slicing, appending, transposing, renaming, dropping rows and columns are demonstrated. Data is loaded from dictionaries into Series and DataFrames and then manipulated.

Uploaded by

Aryan Gaur
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views23 pages

Class 12 Informatics Practices File

The document contains code in Python to perform operations on pandas Series and DataFrames. Various operations like indexing, slicing, appending, transposing, renaming, dropping rows and columns are demonstrated. Data is loaded from dictionaries into Series and DataFrames and then manipulated.

Uploaded by

Aryan Gaur
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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=[Link](['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
[Link]: object

33. #(b)
[Link]=[Link]([0,0,0,0,0],index=['a','e','i','o','u'])
[Link]
36.a 0
37.e 0
38.i 0
39.o 0
40.u 0
[Link]: int64
[Link]
[Link]

44. #(c)
45.d1={'Akshat':1,'Aryan':2,'Avi':3,'Ayush':4,'Vaibhav':5}
[Link]=[Link](d1)
[Link]
[Link] 1
[Link] 2
[Link] 3
[Link] 4
[Link] 5
[Link]: int64

54. #(d)
[Link]=[Link](dtype=int)
[Link]
[Link]([], dtype: int32)
[Link]
[Link]

60. #(e)
61.n1=[Link]([31,28,31,30,31,30,31,31,30,31,30,31])
[Link]=[Link](n1,index=[1,2,3,4,5,6,7,8,9,10,11,12])
[Link]
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
[Link]: int32

77. #QUESTION 6(a)


[Link]=[Link]([10,10,10,10,10],index=['a','e','i','o','u'])
[Link]
80.a 10
81.e 10
82.i 10
83.o 10
84.u 10
[Link]: int64

86. #(b)
[Link]/2
88.a 5.0
89.e 5.0
90.i 5.0
91.o 5.0
92.u 5.0
[Link]: float64

94. #(c)
95.Vowels1=[Link]([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. [Link]=['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=[Link](d1,index=['Madhu','Kusum','Kinshuk','Ankit','Shruti'])
5. d2={2018:[160000,110000,500000,340000,900000]}
6. Sales2=[Link](d2,index=['Madhu','Kusum','Kinshuk','Ankit','Shruti'])
7. #(a)
8. Sales=[Link](Sales2)
9. Sales
10. 2014 2015 2016 2017 2018
[Link] 100.5 12000.0 20000.0 50000.0 NaN
[Link] 150.8 18000.0 50000.0 60000.0 NaN
[Link] 200.9 22000.0 70000.0 70000.0 NaN
[Link] 30000.0 30000.0 100000.0 80000.0 NaN
[Link] 40000.0 45000.0 125000.0 90000.0 NaN
[Link] NaN NaN NaN NaN 160000.0
[Link] NaN NaN NaN NaN 110000.0
[Link] NaN NaN NaN NaN 500000.0
[Link] NaN NaN NaN NaN 340000.0
[Link] NaN NaN NaN NaN 900000.0

21. #(b)
[Link].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)
[Link][2017]
[Link] 50000.0
[Link] 60000.0
[Link] 70000.0
[Link] 80000.0
[Link] 90000.0
[Link] NaN
[Link] NaN
[Link] NaN
[Link] NaN

Page | 8
[Link] NaN
[Link]: 2017, dtype: float64

44. #(d)
[Link][2017]['Madhu']
[Link] 50000.0
[Link] NaN
[Link]: 2017, dtype: float64
[Link][2018]['Madhu']
[Link] NaN
[Link] 160000.0
[Link]: 2018, dtype: float64
[Link][2017]['Ankit']
[Link] 80000.0
[Link] NaN
[Link]: 2017, dtype: float64
[Link]
[Link][2018]['Ankit']
[Link] NaN
[Link] 340000.0
[Link]: 2018, dtype: float64

62. #(e)
[Link][2017]['Shruti']
[Link] 90000.0
[Link] NaN
[Link]: 2017, dtype: float64

67. #(f)
68.Sales2=[Link](d2,index=['Madhu','Kusum','Kinshuk','Ankit','Shruti'])
[Link]=[Link](d1,index=['Madhu','Kusum','Kinshuk','Ankit','Shruti'])
70.Sales3=[Link](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)
[Link] Sales[2014]
[Link]
82. 2015 2016 2017
[Link] 12000 20000 50000

Page | 9
[Link] 18000 50000 60000
[Link] 22000 70000 70000
[Link] 30000 100000 80000
[Link] 45000 125000 90000

88. #(h)
[Link]=[Link]('Kinshuk', axis=0)
[Link]
91. 2015 2016 2017
[Link] 12000 20000 50000
[Link] 18000 50000 60000
[Link] 30000 100000 80000
[Link] 45000 125000 90000

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

103. #(j)
104. [Link][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('[Link]', index = True)

122. #(l)
123. salesr=pd.read_csv('[Link]',names=['2014', '2015', '2016',
'2017'])
124. [Link]=['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;
[Link] 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