Page 332 - Informatics_Practices_Fliipbook_Class12
P. 332
Unsolved
1. Given the following Pandas Series representing the scores of students in an art class, how can you extract the
scores of the top 5 students using indexing and slicing:
artScores = pd.Series([85, 92, 78, 89, 95, 87, 93, 91, 84, 88])
2. Consider the following dictionary containing population data for different cities in a country:
population_dict = {
'New York': 8622698,
'Los Angeles': 3990456,
'Chicago': 2716000,
'Houston': 2320268,
'Phoenix': 1680992
}
Write a Python statement to create a Pandas Series using this dictionary.
3. Consider the following Pandas Series storing names of universities and their locations:
universities = ['Stanford', 'Harvard', 'UC Berkeley', 'MIT', 'UCLA']
locations =['California', 'Massachusetts', 'California', 'Massachusetts',
'California']
univDetails = pd.Series(locations, index = universities)
Write a Python statement to filter the university names to only include universities that are located in
California
4. Consider the following series storing the tuition fees of first five grades of school:
tuitionFees = pd.Series([5000, 6000, 6500, 7000, 8000])
Suppose the school decided to increase the fees by 10%. Write a Python statement to compute updatedFees to
simulate a tuition fee increase.
5. Suppose you have a Pandas Series representing the daily rainfall data for various cities. Check for missing values
(NaN) in the Series and count the number of days with missing data.
rainfallData = pd.Series([0.2, 0.1, 0.4, np.nan, 0.5, np.nan, 0.3, 0.7, 0.2, np.nan])
6. Consider the following series comprising a list of airports:
airports = pd.Series(['Airport A', 'Airport B', 'Airport C', 'Airport D', 'Airport E'])
Write a Python statement to check if a specific airport, let's say "Airport A," is present in the dataset using the
membership operator in.
7. Consider following Pandas Series representing the distance traveled and the time taken by two different trains,
Train P and Train Q, for a journey:
trainPDistance = pd.Series([250, 320, 280, 350, 370])
trainQDistance = pd.Series([200, 260, 220, 300, 310])
trainPTime = pd.Series([3, 4, 3.5, 4.2, 4.5])
trainQTime = pd.Series([2.5, 3.2, 2.8, 3.8, 3.7])
Write a Python statement to calculate the average speed of each train for the journey.
318 Touchpad Informatics Practices-XII

