1. Learn
  2. /
  3. Courses
  4. /
  5. Data Types in Python

Connected

Exercise

Comparisons

Booleans and their truthiness are most often used in comparisions, and we use comparisions without even thinking about their underlying data type. To perform a comparision, we can use a comparision operator. Python supports the following comparision operators:

  • == equal to
  • != not equal to
  • > greater than
  • < less than
  • >= greater than or equal to
  • <= less than or equal to For this exercise, we'll be using a subset of the Palmer Archipelago (Antarctica) penguin data set, named penguins, as a list of dictionaries with the keys of species, flipper_length, body_mass and sex.

Instructions

100 XP
  • Use a for loop to iterate over the penguins list.
  • Check the penguin entry for a body_mass of more than 3300 grams.
  • Print the species and sex of the penguin if true.