IP Practical File Part I - Class XII
IP Practical File Part I - Class XII
Question
Q. 1 Write the Python Program to display the following mathematical Series as well as find the sum of
the series and display it at the last of the printed series.
1 + 1/2 + 1/3 + ….. + 1/N
Q. 2 Write a Python Program to create a list asking the number of elements from the user and then
get the list elements also from the user. Further, find the largest and smallest number from the
List and display it with the suitable message.
Q. 3 Write a program to create a Series object using a dictionary that stores the number of students in
each section of class 12 in your school?
A 39
B 41
C 42
D 44
dtype : int64
Further modify the series for the number of students in Section A to 42 and in Section C and D to
40. Print the modified series.
Q. 4 Write a Pandas program to compare the elements of the two Pandas Series with same length that
is defined in the program itself.
Q. 5 Write a program to add, subtract, multiple and divide two Pandas Series and display the result
with suitable input and output messages accordingly for the following situations:
i) take both the series with same count of elements in each
ii) take the second series with three more elements than the first series.
Q. 6 Write a program to create a dictionary to store names of 10 cities as index with their population
as numeric data as follows:
Indore Ujjain Bhopa Jabalp Gwalio Guna Burhan Ratla Raipur Mandsaur
l ur r pur m
15000 8000 13500 18000 22000 9500 115000 8750 12500 1600000
00 00 00 00 00 00 0 00 00
Q. 7 Write a program to create a Series from the dictionary created in question 6 followed by code
to find the following:
i) Name and population of three cities with largest population
ii) Name and population of three cities with least population
iii) Name and population which has population less than 900000
(Write suitable messages to display on screen to user for communicating input and output)
(Hint: Copy the code from question 3 and paste it in code of question 4 )
Q. 8 Write a program to create the dataframe based on following data and then print it further display
the rows from the dataframe where the height is not known, i.e. is NaN.
'name': ['Asha', 'Radha', 'Kamal', 'Divy', 'Anjali'],
'height': [ 5.5, 5, np.nan, 5.9, np.nan],
'age': [11, 23, 22, 33, 22]
Q. 10 Write a program in Python Pandas to create the following DataFrame batsman from a Dictionary:
Q. 12 Write a program to create a Data Frame Quarterly Sales where each row contains the Quarterly
Sales of TV, Freeze and AC. Show the DataFrame after deleting details of Freeze.
TV Freeze AC
Qrt1 200000 300000 240000
Qtr2 230000 200000 153000
Qtr3 210000 290000 245000
Qtr4 24000 210000 170000
Dataframe after removing Column of Freeze.
TV AC
Qrt1 200000 240000
Qtr2 230000 153000
Qtr3 210000 245000
Qtr4 24000 170000
Q. 13 Write a program to prepare the following dataframe with name aid that stores the aid by NGOs
for different states:
Toys Books Uniform Shoes
Andhra 7916 6189 610 8810
Odisha 8508 8208 508 6978
Gujarat 7226 6149 611 9611
Bihar 7617 6157 457 6457
Further, write the code for
i) To display the aid for Books and Uniform only
ii) To display the aid for Shoes only
iii) Add data for one more state as
(“Punjab”, Toys:6500, Book:7580, Uniform:8000, Shoes:9500)
Python Pandas – I
Practical List for Series and DataFrame
Question
iv) Modify the value of Uniform for Gujarat state to 750
v) Also, find the total amount given for each category of items
(Write suitable messages to display on screen to user for communicating input and output)
Q. 14 Write code to create a DataFrame to store name, age and percentage of 10 students of Class X.
The program should do the following:
i) Print the DataFrame
ii) Display the data of only those students who have secured more than 60 percent.
iii) Display the data of those students who have secured less than or equal to 33
percentage.
iv) Display Total Students Present, Total Student Pass, Total Student Fail
v) Display the Transpose of the dataframe.
vi) Display the summary of performance of students as follows:
Summary
==============================
Hightest percentage in the class is : ……
Lowest percentage in the class is : ……..
(Write suitable messages to display on screen to user for communicating input and output)
Q. 15 Draw the bar graph based on the data available in DataFrame of the Production of two-wheelers
in different Years by a car company “Prestige Automobiles”.
Year: 2000, 2002, 2004, 2006, 2008, 2010, 2012, 2014, 2016, 2018
Production: 4, 6, 7, 15, 24, 2, 19, 8, 16, 14
Apply the following features in the graph:
i) The graph should have headings as “Prestige Automobiles – Production Analysis”
ii) x – axis title should be “Production Year”
iii) y – axis title should be “No. of cars produced (in Thousands)”
iv) The y axis grids should be visible
v) Save the graphs on to the location D:\P1.pdf
Q. 16 Write a program to create a dataframe from the following Lists of data of the birth rate of boys
and girls in the given years of a city Manoharganj as follows. Also, print the dataframe.
Further, create the line graph for analysing the pace of rate of birth of boys and girls in the city.
(continued…..)
Python Pandas – I
Practical List for Series and DataFrame
Question
The data provided in three lists is as follows:
Yr=[2000,2002,2004,2006]
boy=[21.0,20.7,21.2,21.6]
girl=[17.5,19.5,23.0,20.5]
Q. 17 Write a program to create a DataFrame from a CSV file having file name “IH_School_12.csv”.
Display the shape (Number of rows and columns) of the CSV file.
Output example:
Name Percentage Age Location
0 Aryan Juneja 90 16 Indore
1 Bharat Kumar 85 15 Dewas
2 Mayank Tiwari 74 16 Indore
Number of rows : 3
Number of Columns : 4
Q. 18 Write a program to create a DataFrame to store Roll Number, Name and Marks of five students.
Print the DataFrame and its transpose.
Finally, create a CSV file “students.csv” from the original dataframe for future reference.
Python Pandas – I
Practical List for Series and DataFrame
Question
Q. 19 Given datasets population of India and Pakistan in the given years. Show the population of India
and Pakistan using line chart as follows :
i) Chart should have suitable Title
ii) Label on x-axis as “Countries”
iii) Label on y-axis as “Population in Millions”
iv) Legends on left top corner of the chart
Q. 20 A survey gathers height and weight of 60 participants and recorded the Participants’ ages as:
Ages = [ 1, 1, 2, 3, 5, 7, 8, 9, 10, 10, 11, 13, 13, 15, 16, 17, 18, 19, 20, 21, 21, 23, 24, 24, 24, 25,
25, 25, 25, 26, 26, 26, 27, 27, 27, 27, 27, 29, 30, 30, 30, 30, 31, 33, 34, 34, 34, 35, 36, 36, 37, 37,
37, 8, 38, 39, 40, 40, 41, 41 ]