1
1
2
3 GLORIOUS
4 PUBLIC SCHOOL
5
7 INFORMATION PRACTICES
8
9
10
11
12
13
14
15 PROJECT
16 FILE
17 2024-2025
18
2
3
19 INTRODUCTION
20 NAME : Abhinav Chauhan
21 CLASS : XIIth Commerce
22 SUBJECT : Informatics Practices
23 SCHOOL : Glorious Public School
24 SUBMITTED TO : Mrs. Jyoti Sharma
25
26
27
28
4 2
5
29
30 ACKNOWLEDGEMENT
31
32
33
34 I would like to thank my teacher Mrs.Jyoti Sharma and
35 principal Sir Mr.Narender Singh for giving me the
36 opportunity to do this practical file. This also helped
37 me in doing a lot of research and increased my
38 knowledge in difficult topics.
39
40
41
42
43
44
45
46
47
6 3
7
48 INDEX
49 PYTHONPROGRAMS
Sr.No Questions Tr.Sign.
1. Create a series of these numbers:33,55,65,29,19,23.
2. Create a series of 10 numbers starting with 41 and with the
3. increment of 3.
Create a series of 10 numbers using ndarray.
4. Create a series and print the top 3 and bottom 3 elements using
the head and tail functions.
5. Write code to show al attributes of series. Use series in Q1.
6. Use Series created in Q2 ad find output of following
commands:s[::2] , s[1:3] & s[[1,3,4]].
7 Write code to change value 29 and 23 from series Q1.
8. Write code to sort series in descending order-(Use Q3).
9. Create a dataframe countries using a dictionary which stored 5
country name, capitals and populations of the country. Index
will be years.
10. Write a program to show all attributes of dataframe created in
Q9.
11. Create a dataframe players to store 10 players with their
highest and lowest score no_of matches columns. Player names
are indices of dataframe. Perform following questions:a) Show
data of any two players using loc function.
b) Show any two columns.
c) Show data of two rows and two columns using loc function.
d)Make use of rename command to change column name
no_of _matches to Matches_played.
e) Drop row of last player.
12. Make multiple bar graph for dataframe created in Q11.
13. Create line graph for temp. seven days of week.
14. Create histogram to show sales of one month data.
15. Create csv file from dataframe players. Make sure null values are
50
8 4
9
handled properly.
16. Create csv file in excel. Open csv in dataframe. Make use of nrows
51
command.
MYSQLPROGRAMS
1. Create database DATA
Create the following table product
Table: Products
Pcode Pname Qty Price Company
P1001 Ipad 15000 Apple
P1002 LED TV 85000 Sony
P1003 DSLR 25000 Philips
CAMERA
P1004 iPhone 95000 Apple
P1005 LED TV 45000 MI
P1006 Bluetooth 20000 Ahuja
Speaker
2. Show table structure.
3. Show records of table products.
4. Show products of pcode P1001 and P1005.
5.
Show data of products starting with i.
6. Show data of all products whose quantity>50 and price>30000.
7. Show sum of price of all products.
8. Show product names in upper case and also length of all products.
9. Show product name and qty joined with space under heading “Product and Qty”.
10 Display first 2 and last 2 letters from Pname.
.
11 Write queries using empl table:
. Show total employees working in each department.
Show avg salary of each job
Show min salary of each department where minimum employees are > 3.
12 Write queries using empl and dept table:
. Show employee names and location of job.
Show avg salary of employees working in sales department.
Show ename, salary,dname, and location and all employees.
13 Display current date and time.
.
14 Display day of week, day of year and day name for current date.
.
10 5
11
15 Write query to drop the table product.
.
52
53 PYTHONPROGRAM
54 1) Create a series of these numbers: 33,55,65,29,19,23.
55 CODE:import pandas as pd
56 s1=pd.Series([33,55,65,29,19,23])
57 print(s1)
58 OUTPUT:-
59
60 2) Createaseries of 10 numbers starting with 41 and with the increment of3. CODE:import
61 pandas as pd sn = 41
62 im = 3
63 a= [] for i in
64 range(10):
65 a.append(sn)
66 sn = sn+im
67 m=pd.Series(a)
68 print(m)
69 OUTPUT:-
70
71
72 3) Create a series of 10 numbers using ndarray.
12 6
13
73 CODE:import
74 pandas as pd
75 import numpy as
76 np
77 s=pd.Series(np.arange(1, 11))
78 print(s)
79 OUTPUT:-
80
81 4) Create a series and print the top 3 and bottom 3 elements using the head
82 and tail functions. CODE:import pandas as pd s= [10, 20, 30, 40, 50, 60, 70,
83 80, 90, 100]
84 s1 = pd.Series(s)
85 print(s1.head(3))
86 print(s1.tail(3))
87 OUTPUT:-
88
89
90
91
92
93
94 5) Write CODE to show all attributes of series. Use series created in Q1.
14 7
15
95 CODE:import
96 pandas as pd
97 S5=pd.Series([33,55,65,29,19,23])
98 print(S5[:])
99 OUTPUT:-
100
101 6) Use Series created in Q2 and find OUTPUT of following commands:- s[: :2] s[1:3]
102 s[[1,3,4]].
103 CODE:print(m[:
104 :2])
105 print(m[1:3])
106 print(m[[1,3,4]])
107 OUTPUT:-
108
109
110
111
112
113
114
115
116
117 7) Write CODE to change value 29 and 23 from series of Q1.
16 8
17
118 CODE:import
119 pandas as pd
120 s1=pd.Series([33,55,65,29,19,23])
121 s1[3]=30
122 s1[5]=28
123 print(s1)
124 OUTPUT:-
125
126 8) Write CODE to sort series in descending order-(Use Q3).
127 CODE:import
128 pandas as pd
129 import numpy as np
130 s=pd.Series(np.arange(1, 11))
131 print(s)
132 s=s.sort_values(ascending=False)
133 print(s)
134 OUTPUT:-
135
136
137
138
139 9) Create a dataframe countries using a dictionary which stored 5
140 countryname, capitals and populations of the country. Index will be
141 years.
18 9
19
142 CODE:import
143 pandas as pd
144 countries=
145 pd.DataFrame(({
146 'Country': ['USA', 'Canada', 'UK', 'Germany', 'France'],
147 'Capital': ['Washington D.C.', 'Ottawa', 'London', 'Berlin', 'Paris'],
148 'Population': [331002651, 37742154, 67886011, 83783942, 65273511]
149 }), ['2020', '2021', '2022', '2023',
150 '2024']) print(cou ntries)
151 OUTPUT-
152
153 10)Write programto show all attributes of dataframe created in Q9.
154 CODE:import
155 pandas as pd
156 import numpy as np
157 data = {'Country': ['United States', 'France', 'Brazil', 'Japan', 'Australia'],
158 'Capital': ['Washington, D.C.', 'Paris', 'Brasília', 'Tokyo', 'Canberra'],
159 'Population': [1000000, 2000000, 1500000, 2500000, 1800000]}
160 S10 = pd.DataFrame(data, index=[2020, 2021, 2022, 2023, 2024])
161 print(S10[:])
162 OUTPUT-
163 11)
164 Create dataframe players to store 10 players with their highest and lowest
165 score no_of matches columns. Player names are indices of dataframe. perform
166 following questions:-
167 a) Show data of any two players using loc function.
168 b) Show any two columns.
169 c)Show data of two rows and two columns using loc function.
170 d) Make use of rename command to change column name no_of_matches to Matches_played.
171 e) drop row of last player.
20 10
21
172 CODE:import pandas as
173 pd
174 players=pd.DataFrame(
175 {
176 ‘Player': ['Player1', 'Player2', 'Player3', 'Player4', 'Player5', 'Player6', 'Player7', 'Player8', 'Player9',
177 'Player10'],
178 'Highest_Score': [98, 89, 95, 87, 99, 92, 96, 90, 88, 94],
179 'Lowest_Score': [45, 55, 50, 42, 48, 51, 46, 56, 49, 47],
180 'Matches_played': [30, 35, 32, 33, 31, 29, 34, 30, 36, 37]
181 })
182 players.set_index('Player', inplace=True)
183 print('a)Show data of any two players using loc
184 function') print(players.loc[['Player1', 'Player3']])
185 print('b)Show any two columns')
186 print(players[['Highest_Score', 'Lowest_Score']])
187 print('c) Show data of two rows and two columns using loc function')
188 print(players.loc[['Player2','Player5'], ['Highest_Score', 'Lowest_Score']])
189 print('d) Make use of rename command to change column name no_of_matches to
190 Matches_played')
191 players.rename(columns={'Matches_played': 'no_of_matches'},
192 inplace=True) print('Drop the row of the last player') players.drop('Player10',
193 inplace=True) print('Display the updated DataFrame')
194 print(players)
195 OUTPUT:-
196
197
198
199
200 12) Makemultiple bar graph for dataframe created in Q.11
22 11
23
201 CODE:import pandas as pd
202 import matplotlib.pyplot as
203 plt players = pd.DataFrame({
204 'Player': ['Player1', 'Player2', 'Player3', 'Player4', 'Player5', 'Player6', 'Player7', 'Player8', 'Player9',
205 'Player10'],
206 'Highest_Score': [98, 89, 95, 87, 99, 92, 96, 90, 88, 94],
207 'Lowest_Score': [45, 55, 50, 42, 48, 51, 46, 56, 49, 47],
208 'Matches_played': [30, 35, 32, 33, 31, 29, 34, 30, 36, 37]
209 })
210 players.set_index('Player', inplace=True)
211 players[['Highest_Score', 'Lowest_Score']].plot(kind='bar', figsize=(10, 6))
212 plt.title('Highest and Lowest Score for
213 Players') plt.xlabel('Players')
214 plt.ylabel('Scores') plt.xticks(rotation=45)
215 plt.show()
216 OUTPUT:-
217
218
219
220
221 13) Create line graph for temp. of seven days of week
222 CODE:-
223 import matplotlib.pyplot as plt days_of_week = ['Monday', 'Tuesday', 'Wednesday',
224 'Thursday', 'Friday', 'Saturday', 'Sunday'] temperature = [65, 68, 70, 72, 59, 57, 73]
225 plt.plot(days_of_week, temperature, marker='o', linestyle='-') plt.title('Temperature for
226 Seven Days of the Week') plt.xlabel('Day of the Week') plt.ylabel('Temperature (°F)')
227 plt.show()
24 12
25
228 OUTPUT:-
229
230 14) Create histogram to show sales of one month data.
231 CODE:import matplotlib.pyplot as plt
232 sales_data = [110, 125, 125, 145, 135, 115, 110, 120, 135, 140, 130, 130, 140, 175, 135, 145, 125,
233 135, 140, 150, 140, 130, 160, 155, 125, 160, 140,
234 145] plt.hist(sales_data, bins=15, edgecolor='y')
235 plt.title('Sales Histogram for One Month')
236 plt.xlabel('Sales Amount') plt.ylabel('Frequency')
237 plt.show()
238 OUTPUT:-
239
26 13
27
240 15) Createcsv filefrom dataframeplayers. Make surenullvalues are handled properly.
241 CODE:players=pd.DataFrame(
242 {
243 'Player': ['Player1', 'Player2', 'Player3', 'Player4', 'Player5', 'Player6', 'Player7', 'Player8','Player9',
244 'Player10'],
245 'Highest_Score': [100, 150, 80, None, 200, 90, 110, 130, None, 170],
246 'Lowest_Score': [30, 40,20, 50, 60, 35, 25, None, 55, 70],
247 'Matches_played': [50, None, 60, 55, 40, 48, None, 42, 47, 49]
248 })
249 players.set_index('Player', inplace=True)
250 players=players.fillna(‘N/A’)
251 players.to_csv(‘players_data.csv’)
252 OUTPUT:-
253
254 16) Create csv file in excel. Open csv in dataframe. Make use of nrows
255 command. CODE:import pandas as pd
256 Df=pd.read_csv(‘csv.csv’,nrows=5
257 ) print(Df) OUTPUT:-
258
259 MYSQLPROGRAMS
260 Create the following table products.
28 14
29
PCODE Pname Qty Price Company
P1001 iPad 120 15000 Apple
P1002 LED TV 100 85000 Sony
DSLR
P1003 Camera 10 25000 Philips
P1004 iPhone 50 95000 Apple
P1005 LED TV 20 45000 MI
Bluetooth
P1006 Speaker 100 20000 Ahuja
261
30 15
31 Show
262 1) table structure.
263
264 2) Show records of table products.
265
266 3) Show products of pCODE P1001 and P1005.
32 16
33 Show
271
267
268
269
270 4) data of products starting with i.
34 17
35 Show
5) Show data of all products whose quantity >50 and price >30000.
272
273 6) Show sum of price of all products.
274
275 7) Show product names in upper case and also length of all
276 products 8) product name and qty joined with space under
277 heading “product and Qty”.
36 18
37 Show
278
279 9) Display first 2 and last 2 letters from pname.
280
281
282
283
284
285
286
38 19
39
11) Write queries using empl and dept table :
Show employee names and their location of jo b.
Show avg salary of employees working in sales department
Show ename,salary,dname and location of all employee s.
40 21
41
288
12) Display current date and time.
13) Display day of week,day of year and day name for current date.
14) Write query to drop the table product.
42