Category: Python Programs

python tutorials and learn python

Created with Sketch.

Python Program to Check Leap Year

A leap year, also known as an intercalary or bissextile year, is a year that contains an additional day, February 29th. This extra day is added to the calendar in order to keep the calendar year synchronized with the astronomical year. The Gregorian calendar, which is the calendar most widely used today, follows a system…
Read more

Python Program to Check if a Number is Odd or Even

Python Program to Check if a Number is Odd or Even Odd and Even numbers: If you divide a number by 2 and it gives a remainder of 0 then it is known as even number, otherwise an odd number. Even number examples: 2, 4, 6, 8, 10, etc. Odd number examples:1, 3, 5, 7,…
Read more

Python Program to check if a Number is Positive, Negative or Zero

Python Program: Checking if a Number is Positive, Negative, or Zero In this blog post, we will delve into a fundamental Python program that checks whether a given number is positive, negative, or zero. The article will provide a detailed explanation of the algorithm used in the program, present the Python code for implementation, and…
Read more

Python program to display calendar

Python program to display calendar It is simple in python programming to display calendar. To do so, you need to import the calendar module which comes with Python. import calendar  And then apply the syntax (calendar.month(yy,mm)) import calendar<br /> And then apply the syntax<br /> (calendar.month(yy,mm))<br /> See this example: import calendar # Enter the month and year yy = int(input(“Enter year: “)) mm = int(input(“Enter month: “)) # display the calendar print(calendar.month(yy,mm)) import calendar<br /> #…
Read more

Python program to convert Celsius to Fahrenheit

Python program to convert Celsius to Fahrenheit Celsius: Celsius is a unit of measurement for temperature. It is also known as centigrade. It is a SI derived unit used by most of the countries worldwide. It is named after the Swedish astronomer Anders Celsius. Fahrenheit: Fahrenheit is also a temperature scale. It is named on…
Read more

Python program to convert kilometers to miles

Python program to convert kilometers to miles Here, we are going to see the python program to convert kilometers to miles. Let’s understand kilometers and miles first. Kilometer: The kilometer is a unit of length in the metric system. It is equivalent to 1000 meters. Miles: Mile is also the unit of length. It is…
Read more

Python program to generate a random number

Generating Random Numbers in Python with Output Random numbers are a crucial aspect of programming, used in various applications such as simulations, games, and statistical analysis. Python provides the random module, which offers functions to generate pseudo-random numbers. In this post, we’ll explore how to generate random numbers in Python. Using the random Module Python’s…
Read more

Python program to swap two variables

Python program to swap two variables Variable swapping: In computer programming, swapping two variables specifies the mutual exchange of values of the variables. It is generally done by using a temporary variable. For example: data_item x := 1 data_item y := 0 swap (x, y) data_item x := 1<br /> data_item y := 0<br /> swap (x, y)<br /> After swapping: data_item x := 0 data_item y := 1…
Read more

Python program to solve quadratic equation

Python program to solve quadratic equation Quadratic equation: Quadratic equation is made from a Latin term “quadrates” which means square. It is a special type of equation having the form of: ax2+bx+c=0 Here, “x” is unknown which you have to find and “a”, “b”, “c” specifies the numbers such that “a” is not equal to…
Read more

Python program to find the area of a triangle

Python program to find the area of a triangle Mathematical formula: Area of a triangle = (s*(s-a)*(s-b)*(s-c))-1/2 Here s is the semi-perimeter and a, b and c are three sides of the triangle. See this example: # Three sides of the triangle is a, b and c: a = float(input(‘Enter first side: ‘)) b = float(input(‘Enter second side: ‘)) c = float(input(‘Enter third side: ‘)) # calculate the semi-perimeter s = (a + b + c) / 2 # calculate the area area = (s*(s-a)*(s-b)*(s-c)) ** 0.5 print(‘The area of the triangle is %0.2f’ %area) # Three sides of the triangle is a, b and…
Read more