Python Code to Convert Years to Days and Months

Convert the number of Years into the Number of Days and Months using Python


     *Featured code submitted by Femi Ojo via Sololearn.



Python


print("Enter the number of years")
years = int(input())
print (years)
print ("the number of days")
n = years//100
if years > 0:
    if years % 400 == 0:
        o = years//400
        j = n-o
        y = years//4
        e = y-j
        g = years-e
        f = e*366
        h = g*365
        i = f+h
        n_day = int(i)
    else:
      y = years//4
      e = y-n
      g = years-e
      f = e*366
      h = g*365
      i = f+h
      n_day = int(i)
  
print(n_day)
print("the number of months")
month = 12*years
print(month)


Click here to view this code



More Free Code Examples:


Python Code to Reverse a String


Hello World in 10 Programming Languages


8 Codes to Find Versions







Comments

Popular posts from this blog

Multi-tap Keypad Text Entry

Crypto Mining