Files
freecodecamp--freecodecamp/curriculum/challenges/english/blocks/daily-coding-challenges-python/69738771fb5a7b8b24cca2a2.md
T
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

2.3 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
69738771fb5a7b8b24cca2a2 Challenge 176: Groundhog Day 29 challenge-176

--description--

Today is Groundhog Day, in which a groundhog predicts the weather based on whether or not it sees its shadow.

Given a value representing the groundhog's appearance, return the correct prediction:

  • If the given value is the boolean true (the groundhog saw its shadow), return "Looks like we'll have six more weeks of winter.".
  • If the value is the boolean false (the groundhog did not see its shadow), return "It's going to be an early spring.".
  • If the value is anything else (the groundhog did not show up), return "No prediction this year.".

--hints--

groundhog_day_prediction(True) should return "Looks like we'll have six more weeks of winter.".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(groundhog_day_prediction(True), "Looks like we'll have six more weeks of winter.")`)
}})

groundhog_day_prediction(False) should return "It's going to be an early spring.".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(groundhog_day_prediction(False), "It's going to be an early spring.")`)
}})

groundhog_day_prediction(None) should return "No prediction this year.".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(groundhog_day_prediction(None), "No prediction this year.")`)
}})

groundhog_day_prediction(" ") should return "No prediction this year.".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(groundhog_day_prediction(" "), "No prediction this year.")`)
}})

groundhog_day_prediction("True") should return "No prediction this year.".

({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(groundhog_day_prediction("True"), "No prediction this year.")`)
}})

--seed--

--seed-contents--

def groundhog_day_prediction(appearance):

    return appearance

--solutions--

def groundhog_day_prediction(appearance):
    if appearance is True:
        return "Looks like we'll have six more weeks of winter."
    if appearance is False:
        return "It's going to be an early spring."
    return "No prediction this year."