## Python Program to Swap Two Variables

In this example, you will learn to swap two variables by using a temporary variable and, without using temporary variable. Source Code: Using a temporary variable Output The value of x after swapping: 10 The value of y after swapping: 5 In this program, we use the temp variable to hold the value of x temporarily. We then put…

## Python Program to Solve Quadratic Equation

This program computes roots of a quadratic equation when coefficients a, b and c are known. The standard form of a quadratic equation is: ax2 + bx + c = 0, where a, b and c are real numbers and a ≠ 0 Source Code Output Enter a: 1 Enter b: 5 Enter c: 6…

## Python Program to Calculate the Area of a Triangle

In this program, you’ll learn to calculate the area of a triangle and display it. If a, b and c are three sides of a triangle. Then, s = (a+b+c)/2 area = √(s(s-a)*(s-b)*(s-c)) Source Code Output The area of the triangle is 14.70 In this program, area of the triangle is calculated when three sides are given using Heron’s formula. If…

## Python Program to Find the Square Root

In this program, you’ll learn to find the square root of a number using exponent operator and cmath module. Example: For positive numbers Output The square root of 8.000 is 2.828 In this program, we store the number in num and find the square root using the ** exponent operator. This program works for all positive real numbers. But…

## Python Program to Print Hello world!

A simple program that displays “Hello, World!”. It’s often used to illustrate the syntax of the language. Source Code Output Hello, world! In this program, we have used the built-in print() function to print the string Hello, world! on our screen. By the way, a string is a sequence of characters. In Python, strings are enclosed inside single quotes, double quotes,…

## Python Program to Add Two Numbers

Output Enter first number: 1.5 Enter second number: 6.3 The sum of 1.5 and 6.3 is 7.8