python enter the date that the judgment in the first few days

1. Enter the date to determine the date of the first few days of the year

  

iyear = int (input ( "Please enter in: \ the n-")) 
iMonth = int (the INPUT ( "Please enter the month: \ the n-")) 
iDay = int (the INPUT ( "Please enter the day: \ the n-")) 



DEF checkYear (iYear): 
    return (! (iYear. 4 == 0% and 100% iYear = 0) or 400% iYear == 0) 


tol_day = 0 

for I in Range (. 1, iMonth): 
    # = LIS tol_day + [I] 
    IF in I [. 1,. 3,. 5,. 7,. 8, 10, 12 is]: 
        tol_day + = 31 is 
    elif I == 2: 
        tol_day + 28 = 
        IF checkYear (iYear): 
            tol_day + =. 1 
    the else: 
        tol_day = + 30 
tol_day + = iDay 
Print (tol_day) 

or: 
LIS = [0, 31 is, 28, 31 is, 30, 31 is, 30, 31 is, 31 is, 30, 31 is, 30, 31 is] 
# if it is a leap year, February and one day  
if checkYear ( year):
    lis [2 ] = 1 +
# Days traversal time, corresponding to the number of days of the month, the number of days corresponding to the transfer memory tol_day 
for I in Range (month The): 
    tol_day = LIS + [I] 
Print (tol_day + iDay)

.. 2 enter the date, the date is determined from the number of days it is now

#datetime acquisition date 
Import datetime 
datetime.datetime.now () year. 
datetime.datetime.now () month The. 
datetime.datetime.now () Day. 



Import datetime 

DEF FUNC (): 
    the y-the INPUT = ( "Please enter the Year ") 
    m = iNPUT (" Please enter the month ") 
    D = iNPUT (" Please enter the date ") 
    T1 = datetime.datetime.now () # Get the current time 
    t2 = datetime.datetime (int (y) , int (m) , int (d)) # Get the specified time 
    T3 = T2 - T1 
    Print ( "away% s-% s-% s% d days"% (Y, m, D, t3.days)) 
FUNC ()

 3. Print the following:

for i in range(9, 0, -1):
    for k in range(0, 9 - i):
        print("    ", end="\t")
    for j in range(1, i + 1):
        print("{}*{}={:02d}".format(i, j, i * j), end="\t")
    print()



for i in range(1, 11):
    for j in range(1, 11):
        print(" * ", end="")

    print()


print("---------------------------")
for i in range(1, 11):
    for j in range(1, 11):
        if i == 1 or i == 10:
            print(" *  *  *  *  *  *  *  *  *  * ", end="")
            break
        elif  j == 1 or j == 10 :
            print(" * ", end="")
        else:
            print(" . ", end="")
    print()

print("---------------------")

for i in range(1, 11):
    for j in range(1, 11):
        if i == 1 or i == 10:
            print(" *  *  *  *  *  *  *  *  *  * ", end="")
            break
        elif i == j or j == 1 or j == 10 or (i + j == 11):
            print(" * ", end="")
        else:
            print("   ", end="")
    print()


print("---------------------")

for i in range(1, 11):
    for j in range(1, 11):
        if i == 1 or i == 10:
            print(" *  *  *  *  *  *  *  *  *  * ", end="")
            break
        elif i == j or j == 1 or j == 10 or (i + j == 11):
            print(" * ", end="")
        elif i <= j and j + i >= 11:
            print(" $ ", end="")
        else:
            print("   ", end="")
    print()

  

Guess you like

Origin www.cnblogs.com/songdanlee/p/11128961.html