python

python

Python program to find the first odd Abundant or excessive number

In this tutorial, we will learn how to find the first odd Abundant number in python. A number is called Abundant or Excessive number if its sum of all proper divisors is more than the number itself. A proper divisor is any divisor of a number other than the number itself. For a prime number, the only proper divisor is ‘1’. ‘1’ doesn’t have any proper divisor. 6 has two proper divisors 2 and 3.

Read
python

Python program to find larger string among two strings

In this tutorial, we will learn how to find the larger string among two user input strings in python. One string is called larger than another string if its length is greater than the length of the other string. So, we need to find out the length of a string if we want to compare it with another.

Read
python

Python program to count the total number of lines in a file

Python program to find the total number of lines in a file. We will find out the total lines in a text file. With this tutorial, you will learn how to open a file and read its content in python. Python provides inbuilt methods to read, write, and delete a file.

Read
python

Python program to print one identity matrix

In this tutorial, we will learn how to print an identity matrix in python. A matrix is called identity matrix if all of its diagonal elements from the upper left corner to bottom right corner is 1 and all other elements are 0. For example, the following matrices are "identity matrix" :All three matrices are consist of zeroes except the diagonal. The elements for the diagonals from the upper left to the bottom right corner are one.

Read
python

Python range explanation with example

In this tutorial, we will learn python range() function and how to use it using examples. Mainly, range() is used in for loops. It can be defined as below :.

Read
python

Python program to convert a list to string

In this example, we will learn how to convert a list to string. The list is one of the most commonly used datatype in python. List is used to storing a collection of different items. Python list is mutable, ordered and it can also hold duplicate values. In python, list is created by placing all items inside a square bracket ([]). Items are separated by commas. The index of list item starts at 0, i.e. the index of the first element is 0, the index of the second element is 1 etc. We can access any element in a list by using its index. We can also delete or update an element in a list

Read
python

Python program to merge two lists and sort the merged list

Python example program to merge the contents of two lists and sort the merged list. This program takes all inputs from the user.

Read
python

Python program to remove an element from a list using 'del' statement

All items are placed inside a square bracket in a python list. The index of the items starts from 0, i.e. the index of the first element is 0, the index of the second element is 1 etc. We can access any item in a list using its index. Also, the python list is mutable. We can remove or change any item of a list using its index. In this post, I will show you how to remove single or multiple elements from a python list.

Read
python

List all the files in a Zip file using Python 3

In this tutorial, we will learn how to find out all the files of a zip file. For that, we will use 'zipfile' library which is already available in the 'python' package. We will have to use 'import zipfile'. Using this module, we can create, read, write,append and list all the files from a Zip file.

Read
python

Python program to exchange two numbers without using a third number

In this example, we will learn how to exchange two numbers without using any extra variable. We all know to exchange two numbers using a temporary variable. Exchanging two numbers using a third temporary variable is easy. The working process is the same in all programming languages.

Read