3.26 LAB: Leap Year A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are: 1) The year must be divisible by 4 2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400 Some example leap years are 1600, 1712, and 2016. Write a program that takes in a year and determines whether that year is a leap year. Ex: If the input is: 1712 the output is: 1712 - leap year

Answers

Answer 1

Answer:

year = int(input("Enter a year: "))

if (year % 4) == 0:

  if (year % 100) == 0:

      if (year % 400) == 0:

          print(str(year) + " - leap year")

      else:

          print(str(year) +" - not a leap year")

  else:

      print(str(year) + " - leap year")

else:

  print(str(year) + "- not a leap year")

Explanation:

*The code is in Python.

Ask the user to enter a year

Check if the year mod 4 is 0 or not. If it is not 0, then the year is not a leap year. If it is 0 and if the year mod 100 is not 0, then the year is a leap year. If the year mod 100 is 0, also check if the year mod 400 is 0 or not. If it is 0, then the year is a leap year. Otherwise, the year is not a leap year.


Related Questions

If i wanted to change my phones simcard, does anything need transferring, or is it an easy swap?

Answers

Most likely not but I think you’ll have to log in your account like if you have an Apple phone . You’ll have to log into your Apple ID
Other Questions
Find the domain and range of the following relation. Also determine whether the relation is a function,{(42)(4,5),(4.7),(4.9)} When you are finished reading, use the site tohelp you answer this question.The gay rights movement in the 1970s wascharacterized bythe AIDS crisis.a newfound openness.the advancement of the intellectual study ofgay and lesbian issues. The Terry Schiavo case raised several ethical issues about death education, including living wills and euthanasia. Weigh in on this particular case and justify your position. Which of the following is the correct definition of a biography? A. an account of a fictitious experience that relies on figurative language B. an account of a single significant experience in a persons life C. an account of somebodys life written by that person D. an account of somebodys life written or produced by another person Name the first 20 elements of the pereodic table What is the number of this particle in a phosphorus atom?Ap ex A block of mass m is placed on a smooth wedge of inclination . The whole system is accelerated horizontally so that the block does not slip on the wedge. The force exerted by the wedge on the block has a magnitude: (A) mg tan (B) mg sin (C) mg cos (D) mg sec What is inflation and how is it measured and, S2inutes)In the table shown, the sum of each row is shown to the right of the row and the sum of each column isshown below the column.tion 1tion 2KJtion 3JK513tion 4tion 5KJLLtion 6L15tion 7tion 811715tion 9tion 10tion 11What is the value of L?tion 12tion 13 A set of shirt prices are normally distributed with a mean of 45 dollars and a standard deviation of 5 dollars. What proportion of shirt prices are between 37 dollars and 59.35 dollars? You may round your answer to four decimal places. A firm considers to buy a machine in 2020. The cost of that machine is $ 5 000 000. The firm uses 5 year straight line depreciation which allows it to write off $ 1 000 000 depreciation expense each year. The firm is subject to 20% corporate tax rate. The firm's revenue in 2021 is expected to be $ 6 000 000 if the investment is not done. The revenue will be $ 9 000 000 if the investment is done. The firm's total costs (including both COGS and General&Administrative Costs) will be $ 4 000 000 if the investment is not done. The total costs will be $ 5 500 000 if the investment is done. Also the following information is given for the year 2021 Without Investment With Investment Inventories $ 300 000 $ 500 000 Acc. Receivables $ 200 000 $ 300 000 Acc. Payables $ 100 000 $ 150 000 Given the above information, calculate the free cash flow of that investment for the years 2020 and 2021. there are more hydrogen atoms in living organisms than any other atoms are asking is more abundant in the terms Mass why is this statement true Using $3,000,000 as the total manufacturing costs, compute the cost of goods manufactured using the following information. Raw materials inventory, January 1 $ 20,000 Raw materials inventory, December 31 40,000 Work in process, January 1 18,000 Work in process, December 31 12,000 Finished goods, January 1 40,000 Finished goods, December 31 32,000 Raw materials purchases 1,700,000 Direct labor 760,000 Factory utilities 150,000 Indirect labor 50,000 Factory depreciation 400,000 Operating expenses 420,000 a. $3,014,000 b. $3,006,000 c. $3,008,000 d. $2,994,000 Which servers as evidence for a scientific claim Find x. I need it ASAP the declaration of independence provides for freedom of the press.-true -false What is the sum of 2x^2-x and -x-2x^2-2 Which factors affect the rate of photosynthesis select all that apply Which of the following molecules are used by heterotrophs as primary sources of free energy?A. Proteins, carbohydrates, and nucleic acidsB. Carbohydrates, lipids, and proteinsC. Nucleic acids, lipids, and carbohydratesD. Lipids, nucleic acids, and proteins when their center-to-center separation is 50 cm. The spheres are then connected by a thin conducting wire. When the wire is removed, the spheres repel each other with an electrostatic force of 0.2525 N. What were the initial charges on the spheres