Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

leap year

y = int(input())
if (y % 400 == 0) or (y % 100 != 0 and y %4 == 0):
    print(y,"is leap year.")
else:
    print(y,"isn't leap year.")
Comment

how to find leap year

  public static void main(String[] args) {
        int year = 2005;

        if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))){
            System.out.println(year+" leap year");
        }else {
            System.out.println(year+" not a leap year");
        }
    }
Comment

leap year

// works in C, C++, C#, Java, JavaScript, and other C-like languages

// optimal technique
if (((year & 3) == 0 && ((year % 25) != 0) || (year & 15) == 0)) {
  // leap year
}

// classic technique
if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) {
	// leap year
}
Comment

leap year formula

$day = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
$year = 2021;

if (($year % 4 == 0 && $year % 100 != 0) || ($year % 400 == 0)) {
  $day = [ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
  echo "This is leap year - get 366 day";
  
} else {
   echo "This is NOT leap year - get ONLY 365 day";
}
Comment

how can you know if a year is a leap year

leapYear = int(input("Input a Year "))

if leapYear %4 == 0:
    print("Its a leap year")
else:
    print ("Its a normal year")
Comment

Leap year program

#include <stdio.h>

int main() {
   int year;
   year = 2016;

   if (((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0))
      printf("%d is a leap year", year);
   else
      printf("%d is not a leap year", year);

   return 0;
}
Comment

check leap year

def is_leap_year(year):
        """This functon returns True if year is a leap year, returns False otherwise"""
        if year % 4 == 0:
                return True
        return False
Comment

PREVIOUS NEXT
Code Example
Python :: python declare array of size n 
Python :: pandas sort dataframe by column 
Python :: def function python 
Python :: tabula python 
Python :: how do i turn a tensor into a numpy array 
Python :: how to make a def in python 
Python :: compare two dictionaries in python 
Python :: delete tuple from list python 
Python :: python json normalize 
Python :: python update 
Python :: check if a list contains any item from another list python 
Python :: python import from parent directory 
Python :: python to find the biggest among 3 numbers 
Python :: binary, decimal, hex conversion python 
Python :: get the last element from the list 
Python :: pyqt menubar example 
Python :: get the current date and time in python 
Python :: good python ide 
Python :: how to auto install geckodriver in selenium python with .install() 
Python :: python find largest variable 
Python :: python path to python executable 
Python :: count different values in list python 
Python :: python bit shift by 3 
Python :: python random geneator 
Python :: use matplotlib in python 
Python :: Python JSON API example 
Python :: # extract an email ID from the text using regex 
Python :: tkinter button hide 
Python :: Python function to compute factorial of a number. 
Python :: who created python 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =