python

python

Python isinstance() and issubclass() functions

Class and instance are object oriented concepts that most of us are familiar with. All classes in python are derived from a base class called Object class. We can also create a class deriving any other class. This new class is called a childclass or subclass of the main class, and the main class is called parent or superclass.

Read
python

Python program to find out numbers in a list divisible by two numbers

In this python programming tutorial, we will learn how to find all numbers that are divisible by two specific numbers. For example, let’s take a look at the list [1,2,3,4,5]. In this list, numbers that are divisible by 2 and 1 are [2,4]. Our program will do the same thing. The user will enter the values of the list and also the two numbers (let’s say m and n).

Read
python

Python program to find the middle element of an unsorted random number list

Learn how to find the middle element of an unsorted random list of numbers in Python. We will learn how to sort the list and print the middle element of the list with examples.

Read
python

How to create a dictionary from two lists in python

Learn how to create a dictionary from two different user input lists in Python. Our program will ask the user to enter the values for both lists and then it will create one dictionary by taking the values.

Read
python

Four different methods to check if all items are similar in python list

In this python tutorial, we will learn how to check if all items are similar or not in a python list.For example, for the list [1,1,1,1,1], all items are same but for [1,2,1,1,1], all items are not same.We have different ways to solve this problem in python. In this post, I will show you four different methods to solve it. Let's take a look at them :.

Read
python

Use any() function in python to check if anything inside a iterable is True

An iterable is an object that returns an iterator. An iterator is used to iterate through an object. Examples of iterables in python are list, tuple, string, dictionary etc. any() in python is used to check if any element in an iterable is True. That means it will return True if anything inside an iterable is True, else it will return False. The syntax of any() is as below :. True

Read
python

Python add and remove elements from a list

Adding and removing items from a list is required most of the time when we are dealing with a list in our program. For example, suppose you have one list of elements the user has selected from a list. If the user will deselect any list item, you will have to remove that specific value from the list. Again, sometimes you need to insert an item at a specific position, or to the end of the list. So, we have a lot of possibilities that we may encounter in our development journey.

Read
python

Logical operators in Python : Explanation with example

The logical operation is mainly done with conditional statements. These are mainly used with two logical operands if the value of logical operands is either True or False. The result of the logical operator is used for the final decision making. Three different types of logical operators are available in python:.

Read
python

Python program to pad zeroes to a string

In this python programming tutorial, we will learn how to pad extra zeros to a string. For example, if the string is 2, and if we pad three zeros to this string, it will become 0002. Similarly, we can pad zeros to any type of string like 00Hello or 000world. We can pad any number of zeros to a string.

Read
python

Python tutorial to calculate the sum of two string numbers

Finding the sum of two numbers if both numbers are integer or float, is not a problem. But what will happen if the numbers are string variable? Like "10", "20" etc ? In this python tutorial, we will learn how to find the sum of two numbers if both of them are in String.

Read