Skip to content
TheChatArchiveThe Chat Archive
Hugging Facezephyr-7b-beta· Hugging FaceHugging Face Arena Human Preference 55K

write a python script that takes a year as input, then checks if that year is a leap year

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Metallama-2-7b-chat’s answer.
  1. User

    write a python script that takes a year as input, then checks if that year is a leap year

  2. Hugging Face Assistant

    Here's a Python script that takes a year as input and checks if it's a leap year:

    def is_leap_year(year):
        # A year is a leap year if it's divisible by 4,
        # except for century years (years ending in 00)
        # unless they're also divisible by 400
        if year % 4 != 0:
            return False
        elif year % 100 == 0:
            return year % 400 == 0
        else:
            return True
    
    # Prompt the user to input a year
    year = int(input("Enter a year to check if it's a leap year: "))
    
    # Call the function to check if the year is a leap year
    if is_leap_year(year):
        print(year, "is a leap year.")
    else:
        print(year, "is not a leap year.")
    

    In this script, the is_leap_year function takes a year as an argument, and returns True if it's a leap year, and False otherwise. The function follows the leap year rule, which is:

    • A year is a leap year if it's divisible by 4
    • Except for century years (years ending in 00), unless they're also divisible by 400

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.