classmethod & staticmethod

Lab Python Advanced 30 points

Create Date with __init__(day, month, year), a @classmethod from_string("DD-MM-YYYY") and a @staticmethod is_leap(year). Read a date string and print it as YYYY/MM/DD followed by leap or common.

Input

One date DD-MM-YYYY.

Output

One line.

Example

Input

16-10-2026

Output

2026/10/16 common
Sample input available Sample output available
Editor
Python

Hints

A classmethod receives the class (cls) and is often used as an alternative constructor.

A staticmethod receives neither self nor cls.

Solution explanation

Use @classmethod for alternative constructors and @staticmethod for helpers that belong with the class but need no instance.

Show solution
class Date:
    def __init__(self, day, month, year):
        self.day = day
        self.month = month
        self.year = year

    @classmethod
    def from_string(cls, text):
        day, month, year = map(int, text.split("-"))
        return cls(day, month, year)

    @staticmethod
    def is_leap(year):
        return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)


d = Date.from_string(input())
kind = "leap" if Date.is_leap(d.year) else "common"
print(f"{d.year:04}/{d.month:02}/{d.day:02} {kind}")
Output
Answer
HOME LEARN COMMUNITY DASHBOARD