Given a list l of n integers. The task is to find the sum of the product of each element with each element after it in the list. In other words, we have to find the sum of the product of each l[i] with each l[j] such that j > i. Let’s see an example […]
Author: Ankit Rai
Python program to find the roots of a quadratic equation
In this article, We will be going to see How to find the roots of a quadratic equation: A*x^2 + B*x + C. Example: Input: Quadratic Equation: 1X^2 + 5X + 2 Output: The Roots of a Quadratic Equations are: -0.4384 and -4.5616 for finding the roots we are using given below rules: D = […]
Python program to convert Centimeter into Inches
In this article, We will see How to Convert the Centimeter unit into Inches. Example: Input: Centimeter: 8 Output: Inches: 3.152 As we know that, 1 centimeter = 0.394 inches (approx) so we are using this information for writing this program. Now, let’s see the different ways to code this program: Code 1: Output: Centimeter […]
Python program to add two numbers
In this Article, We will see How to add two numbers in Python. Example: Input: number1 = 12, number2 = 13 Output: 25 Input: number1 = 10, number2 = 40 Output: 50 Now, let’s see the different ways to code: Code 1: Output: 25 Code 2: Output: 25 Code 3: Output: Enter 1st Number: 10 […]
Python program to calculate Median of a integer list
In this post, we will see the Python program for calculating the median of a given integer list. Examples: Given list: [10, 20, 30, 40, 0, 12, 100] Median of the given data is : 20 Given list: [10, 20, 30, 40, 0, 12, 100, 200] Median of the given data is : 25.0 Now, […]
Python – Different ways to Reverse a String
In this post, We will see different ways to Reverse a string in Python. Code 1: Using the concept of string-Slicing. Output: Reverse String: nohtimehcoiB Code 2: Using the concept of Looping and string-Concatenation. Output: Reverse String: nohtimehcoiB Code 3: Using the concept of Reverse Looping. Output: Reverse String: nohtimehcoiB Code 4: Using reversed(),list() and […]
Python – Number Guessing Game
In this post, we will see how to make a number guessing game in python. So, let’s talk about the game, the user guesses a number in the fixed range then the program tells it is a correct guess or not. If not then the user can guess again. Now, we have to do the […]
Python – Program to Find Circumference of a Circle
In this post, we will write a program for how to calculate circumference of a circle in python. First, let’s see What is Circumference of Circle? The perimeter is the curve length around any closed figure. Formula: Circumference of Circle: C = 2 * pi * r Where, r = Radius of circle pi = […]
Data Types in Python
As we know Python is an object-oriented programming language so everything is considered as an object in Python, data types are actually classes and variables are instance (object) of these classes. Depending upon the properties, there are manly 7 basic data types: 1. Numbers: This datatype mainly has a numerical value. Integer Float Complex Output: […]
Python – program to print odd natural number upto n
In this post, we will see programs for how to print odd natural numbers up to n in python, provided n is positive. Odd Number : Any integer either positive or negative, which can not be divided exactly by 2 is an odd number. The numbers having the last digit is 1, 3, 5, 7 […]