python

python

Python program to find the square root of a number

A square root of a number X is a number Y if the square of Y is equal to X or the value of Y * Y is equal to X. In this tutorial, we will learn how to find out the square root of a number in Python.

Read
python

Python program to find the multiplication of all elements in a list

Python list is one of the most used datatypes. A list can contain an infinite number of items. It the list is empty, it is called an empty list. List items have different datatypes i.e. it can hold elements of string, integer, float or any other types.

Read
python

Python 3 Ordered Dictionary (OrderedDict) with example

Learn what is ordered dictionary in python with different examples. Examples to create normal dictionary, ordered dictionary, pop item from ordered dictionary and how to compare ordered dictionaries.

Read
python

Python tutorial to remove duplicate lines from a text file

Learn how to remove all duplicate lines from a text file in Python. The program will remove all duplicate lines from an input file and write it to an output file. Also learn how to handle exceptions for invalid file path.

Read
python

Python program to find the maximum and minimum element in a list

In this tutorial, we will learn how to find the maximum and minimum number in a python list. Python list can hold items of any data types. All items are separated by a comma and placed inside a square bracket. We can access any item by using its index. The index starts at 0. The index for the first element is 0, the index of the second element is 1 etc.

Read
python

How to copy or clone a list in python

In this tutorial, we will learn how to copy or clone a list in python. After python 3.3, one new inbuilt method was added to copy a list. We will see two different processes to copy a list in python. Method 1 can be used in both python 2 and 3. But method 2 can only be used with python 3.

Read
python

Python program to replace character in a string with a symbol

In this tutorial, we will learn how to replace all occurrences of a character with a different symbol. First, we will take all the inputs from the user- String, character to replace and the symbol. Our program will replace the character with the symbol in the string.

Read
python

Python program to print a right angled triangle

In this tutorial, we will learn how to print one right angled triangle using python 3. A triangle is called a right angled triangle if it’s one angle is of 90 degree or right angle.

Read
python

Python time.sleep method explanation with Example

In python, we have one method to pause the execution of a program - 'sleep()'. This method is available in 'time' module. In this tutorial, we will learn how to pause a program for a specific time interval using sleep.

Read
python

Python program to remove characters from odd or even index of a string

In this example, we will write one program in Python 3 to remove all characters positioned on Even or Odd index. Python string is immutable, i.e. we can’t modify one string directly. e.g. if you want to change the character on index 3, you can’t change it directly like arrays. We need to create one different string if we want to make any modification to a string.

Read