In this article, We will see different ways to write a Python code to find the maximum of two numbers. Examples: Input: number1 = 10, number2 = 5 Output: 10 Input: number1 = 25, number2 = 50 Output: 50 Now, let’s see the different ways to code this program: Code 1: By using Comparison Operator. […]
Category: Python
Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991…
In this category, we will cover topics like data types, operators, keywords, functions, loops, conditional statements, etc….
Python | Program that matches a word containing ‘a’ in the given string by using regular expression
Given a statement(string), the task is to check if that string contains any word which contains ‘a’ in it then print that word otherwise print no any word containing ‘a’ in the inputted string. Examples: Input: Graphic Era Deemed to be University Output: Graphic Era Input: Geeks for Geeks Output: no any word containing ‘a’ […]
Python – Program to accept only binary string
In this problem a string is given, our task is to check the string is a binary string or not i.e. in the form of 1’s or 0’s or both 1’s and 0’s. Examples: Input : ‘01010101010’ Output : Accepted Input : ‘geeks101’ Output: Not Accepted Approach 1: We firstly create a set of the […]
Python | program to check each string in the list of strings whether it is palindrome or not and showing that result in the list of tuple forms.
A string is said to be palindrome if the reverse of the string is the same as the string. For example, “naman” is a palindrome, but “ankit” is not a palindrome. Iterative Method: Run a loop from start to half of the length of the string. Check the first character to the last character of […]
Python – Sum of product of each element with each element after it in the List.
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 […]
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, […]
Set up Python virtual environment using Anaconda
While working with python, we usually face the problem of setting up the virtual environment. In this blog I have covered the steps of creating virtual environment in python. Anaconda : Anaconda is an open source software that contains Jupyter, spyder idle etc that are used for large data processing, data analytics, heavy scientific computing. […]