Home > other >  Bosses, I write a perpetual calendar, how to join leap year leap year judgment
Bosses, I write a perpetual calendar, how to join leap year leap year judgment

Time:12-01

The from tkinter import *
The import calendar
The import calendar
Def the close () :
Win. Destroy
Def win_calendar () :
New_win=Tk () c # to create window
New_win. Title (" calendar ") # title
New_win. Geometry (" 666 x666 ") # page size
Fetch_year=int (year_ent. The get ())
Cal_content=calendar. Calendar (fetch_year)
Cal_year=Label (new_win, text=cal_content, the font="Consolas 10 bold")
Cal_year. The grid (row=5, the column=1, padx=20) # typesetting
New_win. Mainloop ()
Win=Tk ()
Win the title (" calendar ")
# tag page changes
The head=Label (win, text="CALENDAR", bg="dark gray", the font=(" times ", 28, "bold"))
Year=Label (win, text="year", the font=(" Arial ", 14 "bold"))
Year_ent=Entry (win, width=10, the font="Arial", (14)) # input time input box
# enter launch button
Show=Button (win, text="show", the font=(12, "Arial", "bold"), bg="light green", the command=win_calendar)
The quit Button=(win, text="quit", the font=(12, "Arial", "bold"), bg="orange", the command=close)
Head. The grid (row=1, columnspan=3, padx=20)
# beautiful increase line spacing
Win. Grid_rowconfigure (2, minsize=10)
Year. The grid (row=3, column=1)
Year_ent. The grid (row=3, column=2, padx=25)
Win. Grid_rowconfigure (4, minsize=10)
The show. The grid (row=5, the column=1, padx=20)
The quit. The grid (row=5, the column=2, padx=20)
# enter circulation
Mainloop ()

CodePudding user response:

Enter the year, see first can be divided exactly by 100, if you can, then watch can be divided exactly by 400, if can also is a leap year, 2000, for example, if not exactly divisible by 400 is a leap year, 1900, for example, if you can't exactly divisible by 100, see can be divided exactly by 4, if aliquot 4 is a leap year, 2008, for example, if you can't is a leap year, for example 1999
A=input (' input year ')
If the int %==0 100: (a)
If the int %==0 400: (a)

Print (f '{a} year is a leap year')
The else:
Print (f '{a} year is a leap year')
The else:
If the int (a) % 4==0:

Print (f '{a} year is a leap year')
The else:
Print (f '{a} year is a leap year')