Q) Write a program that takes the duration of a year (in fractional days) for an imaginary planet as an input and produces a leap-year rule that minimizes the difference to the planet’s solar year.
Also mention the logic you have used to write the program just to ensure that you have made it.
THE LAST SUBMISSION DATE IS TUESDAY(5/5/20) before 9 pm
write using the code snipped option given
the answer will be uploaded on Wednesday(5/5/20) at 12 noon
Enjoy!!
by :
LeisureDown😀😀😃
THIS IS THE SOLUTION TO THE FIRST PROBLEM
PYTHON:
duration_of_year=input("enter the duration of the year in the form of a fraction")
lst=duration_of_year.split("/")
numerator,denominator=lst[0],lst[1]
numerator,denominator=int(numerator),int(denominator)
no_of_normal_days=numerator//denominator
fractional_part=(numerator%denominator)/denominator
no_of_years_before_a_leap_year=1/fractional_part
print("the leap year occurs in every",no_of_years_before_a_leap_year,"years")
LOGIC:
if 1461/4 Is given (which is equal to 365 1/4 days)(earth)
so there will be 365 days in normal years and in every 4 years there will be a leap year(reciprocal of 1/4)
Hope you enjoyed the problem!!😀😀
Regards:
LeisureDown