Found 10805 Articles for Python

Data analysis and Visualization with Python program

Hafeezul Kareem
Updated on 01-Nov-2019 07:58:30

200 Views

In this tutorial, we are going to learn about data analysis and visualization using modules like pandas and matplotlib in Python. Python is an excellent fit for the data analysis things. Install the modules pandas and matplotlib using the following commands.pip install pandaspip install matplotlibYou will get a success message after the completion of the installation process. We will first learn about the pandas and then will see matplotlib.pandasPandas is an open-source library of Python which provides data analysis tools. We are going to see some useful methods from the pandas for data analysis.Creating DataFramesWe need multiple rows to create ... Read More

type and isinstance in Python program

Hafeezul Kareem
Updated on 01-Nov-2019 07:49:32

76 Views

In this tutorial, we are going to learn about the type and isinstance built-in functions of Python. These functions are used to determine the type of an object in general. Let's see them one by one.type(object)type is used to know the type of an object. For example, if we have an object val with value 5. The type of that object is int. We can get that using the type function. Let's follow the general procedure to achieve the result.Initialize the object.Get the type of the object using type(object) function.Display the type.Below is one example which explains the type(object) function.Example# ... Read More

Automated software testing with Python

Hafeezul Kareem
Updated on 01-Nov-2019 07:51:47

516 Views

In this tutorial, we are going to learn about automating testing in Python. After writing code, we have to test them by giving different types of input and check whether the code is working correctly or not.We can do it manually or automatically. Doing manual testing is very hard. So, we are going to learn about automated testing in Python. Let's start.We have a module called unittest, which is used to test the code automatically. We are going to work with this module in this tutorial. It's straightforward for a beginner to get started with the unittest module for testing. ... Read More

Amazing hacks of Python

sudhir sharma
Updated on 24-Oct-2019 07:49:28

112 Views

Python is an amazing programming language that can do many interesting things due to its huge set of libraries. Here are some common hacks and things that will be helpful to you while programming.SSPrinting the same character multiple times in python.Printing repeated character by typing the same character set as many times as we want or looping through if the values are large is commonly used in other programming languages. But python has something else in its trunk to ease this printing of recursive characters.The below code is used to print recursive characters in python, Exampleprint("I love program at tutorials ... Read More

Find all the patterns of “1(0+)1” in a given string using Python Regex

Pradeep Elance
Updated on 23-Oct-2019 08:22:30

142 Views

In this tutorial, we are going to write a program which finds all the occurrences of the 1(0+1) in a string using the regexes. We have a re module in Python which helps us to work with the regular expressions.Let's see one sample case.Input: string = "Sample 1(0+)1 string with 1(0+)1 unnecessary patterns 1(0+)1" Output: Total number of pattern maches are 3 ['1(0+)1', '1(0+)1', '1(0+)1']Follow the below steps to write the code for the program.Algorithm1. Import the re module. 2. Initialise a string. 3. Create a regex object using regular expression which matches the pattern using the re.compile(). Remember to ... Read More

Check if both halves of the string have the same set of characters in Python

Pradeep Elance
Updated on 23-Oct-2019 08:20:20

77 Views

We have to check whether two halves of a string have the same set of characters or not in Python. The frequency of the characters in the two halves must be identical. If the length of the string is odd, ignore the middle and check for the remaining characters. Follow the below steps to write code for the program.Algorithm1. Initialize a string. 2. Initialize an empty dictionary variable alphabets. 3. Initialize a variable mid with length / 2. 4. Write a loop until mid element.    4.1. Initialize the corresponding dictionary item by alphabets[char] with one if it's not initialized. ... Read More

Basic calculator program using Python program

Pradeep Elance
Updated on 23-Oct-2019 08:14:26

985 Views

In this tutorial, we are going to build a basic calculator in Python. I think all of you have an idea about the basic calculators. We will give six options to the user from which they select one option, and we will perform the respective operation. Following are the arithmetic operations we are going to perform.AdditionSubtractionMultiplicationDivisionFloor DivisionModuloTry to implement it's on your own. Follow the below steps to write code for a simple calculator.Algorithm1. Initialise the two numbers. 2. Ask the user to enter an option by giving six options. 3. After getting the option from the user write if ... Read More

Calculate n + nn + nnn + … + n(m times) in Python program

Pradeep Elance
Updated on 23-Oct-2019 08:08:59

2K+ Views

We are going to write a program that calculates the following series in Python. Examine the example inputs and outputs for the program that we are going to write.Input: 34 3 + 33 + 333 + 3333 Output: 3702Input: 5 5 5 + 55 + 555 + 5555 + 55555 Output: 61725So, we will have two numbers, and we have to calculate the sum of the series generated as above. Follow the below steps to achieve the output.Algorithm1. Initialize the number let's say n and m. 2. Initialize a variable with the value n let's say change. 3. Intialize a ... Read More

FuzzyWuzzy Python library

Pradeep Elance
Updated on 23-Oct-2019 08:01:52

471 Views

In this tutorial, we are going to learn about the FuzzyWuzzy Python library. FuzzyBuzzy library is developed to compare to strings. We have other modules like regex, difflib to compare strings. But, FuzzyBuzzy is unique in its way. The methods from this library returns score out of 100 of how much the strings matched instead of true, false or string.To work with the FuzzyWuzzy library, we have to install the fuzzywuzzy and python- Levenshtein. Run the following commands to install them.pip install fuzzywuzzyIf you run the above command, you will the following success message.Collecting fuzzywuzzy Downloading https://files.pythonhosted.org/packages/d8/f1/5a267addb30ab7eaa1beab2 b9323073815da4551076554ecc890a3595ec9/fuzzywuzzy-0.17.0-py2.py3-none-any.whl Installing collected ... Read More

Print anagrams together in Python using List and Dictionary

Pradeep Elance
Updated on 23-Oct-2019 07:52:49

466 Views

In this tutorial, we are going to write a program which finds and prints anagrams using list and dictionary. We have different approaches to every problem. Try to write code without following the tutorial. If you are not able to generate any ideas to write logic, follow the below steps.Algorithm1. Initialize a list of strings. 2. Initialize an empty dictionary. 3. Iterate through the list of strings.    3.1. Sort the string and check if it is present in the dictionary as key or not.       3.1.1. If the sorted string is already present dictionary as a key ... Read More

Advertisements