Ad

A year is a leap year under the following conditions:

  1. year is divisible by 4.
  2. if year if divisible by 100, it must be divisible by 400

e.g. 1600 is a leap year, 1700 is not

Write a function to return whether the year is a leap year or not

bool isLeap(int year) {
  bool leap = true;
  if(year % 4 != 0){
    leap = false;
  } 
  if(year % 100 == 0 && year % 400 != 0) {
    leap = false;
  }
  return leap;
}
Code
Diff
  • def sum(a,b):
        return a + b 
    • def sum(a,b):
    • return a + b + 2 - 3 + 1
    • return a + b

Write a function to add two numbers a and b

def sum(a,b):
    return a + b + 2 - 3 + 1