Solution - Class Test July-1
Solution - Class Test July-1
Class –XII
[Solution of July 2024 class Test]
1. What is the primary data structure of the Pandas library? a) Array b) Series
c) DataFrame d) List
Answer: c) DataFrame
3. How do you select the 'age' column from a DataFrame df? a) df.age b) df[‘age’]
c) df[[‘age’]] d) All of the above
Answer: d) All of the above
4. Which method is used to read a CSV file into a Pandas DataFrame? a) pd.read_csv() b) pd.load_csv()
c) pd.open_csv() d) pd.import_csv()
Answer: a) pd.read_csv()
5. What does the head() method do in Pandas? a) Shows the first 5 rows of a DataFrame b) Shows the last 5
rows of a DataFrame
c) Shows the structure of a DataFrame d) Shows the summary of a DataFrame
Answer: a) Shows the first 5 rows of a DataFrame
6. Which of the following is used to get the dimensions (rows, columns) of a DataFrame? a) df.shape b)
df.size
c) df.count d) df.length
Answer: a) df.shape
7. What will s = pd.Series([1, 2, 3], index=['a', 'b', 'c']) return? a) A Series with default integer index b) A
Series with indices 'a', 'b', 'c'
c) An error d) A Series with reversed values
Answer: b) A Series with indices 'a', 'b', 'c'
8. How can you access the first element of a Pandas Series s? a) s[1] b) s[-1]
c) s[0] d) s.first()
Answer: c) s[0]
10. How do you add two Pandas Series s1 and s2 element-wise? a) s1 + s2 b) s1.add(s2)
c) pd.concat([s1, s2]) d) Both a and b
Answer: d) Both a and b
3) How can you check the data types of each column in a DataFrame?
Answer: Use df.dtypes.