Leap Year Check in Python
Leap Year Check in Python
Program:
Output
RUN 1:
Enter the value of year: 2020
The given year is a leap year.
RUN 2:
Enter the value of year: 2021
The given year is a non-leap year.
2) By simply checking the leap year condition
As we know the condition to check the given year is a leap year or not.
So, here we will implement the condition and try to write the Python program.
Program:
To find the square of a number - simple multiple the number two times.
Program:
# input a number
number = int (raw_input ("Enter an integer number: "))
# calculate square
square = number*number
# print
print "Square of {0} is {1} ".format (number, square)
Output
Program:
# input a number
number = int (raw_input ("Enter an integer number: "))
# calculate square
square = number**2
# print
print "Square of {0} is {1} ".format (number, square)
Output
pow(m,n) is an inbuilt method of math library, it returns the value of "m to the power
n". To use this method, we need to import math library in the program.
Program:
# input a number
number = int (raw_input ("Enter an integer number: "))
# calculate square
square = int(math.pow (number, 2))
# print
print "Square of {0} is {1} ".format (number, square)
Output