write a python script that takes a year as input, then checks if that year is a leap year
- User
write a python script that takes a year as input, then checks if that year is a leap year
Assistant
Sure! Here is a simple Python script that takes a year as input and checks if it is a leap year:
def is_leap_year(year): # Check if year is divisible by 4 if year % 4 == 0: # Check if year is also divisible by 100 if year % 100 == 0: # If year is divisible by 400, it is a leap year return True return False # Test the function with some examples print(is_leap_year(2023)) # Output: True print(is_leap_year(2024)) # Output: False print(is_leap_year(1900)) # Output: False print(is_leap_year(2000)) # Output: True
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.