Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. def MyDate(yer):
  2.     Array = []
  3.     i = 1
  4.  
  5.     while i <= 12:
  6.         j = 1
  7.         Array += [[]]
  8.         if str([i]) in "[1],[3],[5],[7],[8],[10],[12]":
  9.             while j <= 31:
  10.                 Array[i - 1] += [j]
  11.                 j += 1
  12.         elif str([i]) in "[4],[6],[9],[11]":
  13.             while j <= 30:
  14.                 Array[i - 1] += [j]
  15.                 j += 1
  16.         elif str([i]) in "[2]":
  17.             if yer % 4 == 0 and yer % 100 != 0:
  18.                 while j <= 29:
  19.                     Array[i - 1] += [j]
  20.                     j += 1
  21.             else:
  22.                 while j <= 28:
  23.                     Array[i - 1] += [j]
  24.                     j += 1
  25.         i += 1
  26.     return Array
  27.  
  28.  
  29. def MyCheck(day, month, MyDate):
  30.     k = 0
  31.     value = 1
  32.     for i in MyDate:
  33.         for j in MyDate[k]:
  34.             if day == j and month == k + 1:
  35.                 return value
  36.             value += 1
  37.         k += 1
  38.  
  39.  
  40. if __name__ == "__main__":
  41.     print(MyCheck(1, 1, MyDate(1996)))
  42.     print(MyCheck(21, 7, MyDate(1996)))
  43.     print(MyCheck(31, 12, MyDate(1996)))
  44.     print(MyCheck(33, 7, MyDate(1996)))
  45.     print(MyCheck(-3, 7, MyDate(1996)))
  46.     print(MyCheck(21, -7, MyDate(1996)))
  47.     print(MyCheck(21, 13, MyDate(1996)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement