Day: January 2, 2021

Python Examples for Beginners: Python Code to Swap Two Variables

(Python Tutorials for Citizen Data Scientist) Python Code 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 # Python program to swap two variables x = 5 y = 10 # To take inputs …

Python Examples for Beginners: Python Code to Solve Quadratic Equation

(Python Tutorials for Citizen Data Scientist) 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 …

Python Examples for Beginners: Python Code to Calculate the Area of a Triangle

(Python Tutorials for Citizen Data Scientist) 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 # Python Program to find the area of triangle a …

Python Examples for Beginners: Python Code to Find the Square Root

(Python Tutorials for Citizen Data Scientist) 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 # Python Program to calculate the square root # Note: change this value for a different result num = …