Skip to main content

Featured

Introduction to Numpy Library in Python

Introduction to Numpy Library in Python NUMPY - Introduction Introduction     NUMPY stands for Numerical Python. Numpy is one of the libraries for the python programming language. It is used for high level mathematical calculations. It has the large collection of functions for working with the multi-dimensional arrays, matrices, linear algebra, Fourier transform, etc. Installation of Numpy 1. Open the command or terminal on your system. 2. Enter the following command below.      #installation of NUMPY using PIP      pip install numpy       (OR)       #installation of NUMPY using CONDA      conda install numpy 3. Now, NUMPY installed on your system. To verify that use the command below.      #check for version of NUMPY      numpy --version  Tip : Use Anaconda Navigator , it comes with built-in software of JUPYTER NOTEBOOKS and pre-installed packages like Nump...

Program to Check Whether a Given Year is a Leap Year in Python

Python - Program to Check Whether a Given Year is a Leap Year

Python - Program to Check Whether a Given Year is a Leap Year
Python - Program to Check Whether a Given Year is a Leap Year


Source Code

Aim :

    To write a program to check whether a given year is a leap year.

Algorithm :

  • Get the required input from the user by using input statement for 'year' represents the checked year .
  • Check whether a given year is leap year or not using the following (year%4==0 and year%100!=0 or year%400==0) in the 'if' statement condition.
  • Display the result with the help of print statement

Program :

#Program to check whether a given year is a leap year
#'year' represents the checked year and get input from user
year = int(input("Enter year to be checked : "))
if(year%4==0 and year%100!=0 or year%400==0):
    print(f"The year {year} is a leap year")
else:
    print(f"The year {year} is not a leap year")

Output :

Enter year to be checked : 
2000
The year 2000 is a leap year

Terminal Code :

Python - Leap Year Program
Python - Leap Year Program

Terminal Output :

Python - Leap Year Output
Python - Leap Year Output

Result :

    The output was executed successfully and result was verified.


Personal Writings for Readers!!!

Story behind single family described in Pandemic Family Book.


Read more on...

Paperback - https://amzn.to/34NS6Sk

Amazon Kindle - https://amzn.to/3aKtIng

Kobo Writing - https://bit.ly/3iQysNy

Comments

Popular Posts