🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: pandas Basics: all 10 questions

Quiz: pandas Basics · Question 8 of 10

What does this print? (code)

What does this print?

import pandas as pd
df = pd.DataFrame({"city": ["Pune", "Jaipur", "Pune", "Delhi"], "cgpa": [7.2, 8.9, 8.1, 6.5]})
print(df[df["city"].isin(["Pune", "Delhi"]) & (df["cgpa"] > 7)]["cgpa"].tolist())
  1. A.[7.2, 8.1]
  2. B.[7.2, 8.1, 6.5]
  3. C.[8.9]
  4. D.[6.5]
Answer & explanation

Correct answer: [7.2, 8.1]

Delhi's 6.5 fails the CGPA condition; Jaipur fails the city condition.

Can you get the rest right without peeking?

Take the timed Quiz: pandas Basics quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →