
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10476 Articles for Python

1K+ Views
In this tutorial, we are going to see how to make a column of names to uppercase in DataFrame. Let's see different ways to achieve our goal.ExampleWe can assign a column to the DataFrame by making it uppercase using the upper() method.Let's see the code.# importing the pandas package import pandas as pd # data for DataFrame data = { 'Name': ['Hafeez', 'Aslan', 'Kareem'], 'Age': [19, 21, 18], 'Profession': ['Developer', 'Engineer', 'Artist'] } # creating DataFrame data_frame = pd.DataFrame(data) # displaying the DataFrame print('---------------------Before-------------------') print(data_frame) print() # making the Name column strings to upper case data_frame['Name'] = ... Read More

951 Views
In this tutorial, we are going to learn about the arithmetic operations on Images using OpenCV. We can apply operations like addition, subtraction, Bitwise Operations, etc.., Let's see how we can perform operations on images.We need the OpenCV module to perform operations on images. Install the OpenCV module using the following command in the terminal or command line.pip install opencv-python==4.1.1.26If you run the above command, you will get the following successful message.Collecting opencv-python==4.1.1.26 Downloading https://files.pythonhosted.org/packages/1f/51/e0b9cef23098bc31c77b0e0 6221dd8d05119b9782d4c2b1d1482e22b5f5e/opencv_python-4.1.1.26-cp37-cp37m-win_amd64.w hl (39.0MB) Requirement already satisfied: numpy>=1.14.5 in c:\users\hafeezulkareem\anaconda3\l ib\site-packages (from opencv-python==4.1.1.26) (1.16.2) Installing collected packages: opencv-python Successfully installed opencv-python-4.1.1.26AdditionWe can add two images using ... Read More

398 Views
In this tutorial, we are going to write a program that returns two numbers whose ratio is equal to the given float value. We have a method called as_integer_ratio() that helps to achieve our goal.Let's see some examples.Input: 1.5 Output: 3 / 2 Input: 5.3 Output: 5967269506265907 / 1125899906842624Let's examine the code.Example# initializing the float value float_value = 1.5 # getting integers tuple using the as_integer_ratio() method integers = float_value.as_integer_ratio() # printing the integers print(f'{integers[0]} / {integers[1]}')OutputIf you run the above code, you will get the following results.3 / 2 Let's see another example.Example# initializing the float value float_value = ... Read More

321 Views
In this tutorial, we are going to perform arithmetic operations on images using OpenCV in Python. We need to install the OpenCV module.Run the following command to install the OpenCV module.pip install opencv-python==4.1.1.26If you run the above command, you will get the following successful message.Collecting opencv-python==4.1.1.26 Downloading https://files.pythonhosted.org/packages/1f/51/e0b9cef23098bc31c77b0e0 6221dd8d05119b9782d4c2b1d1482e22b5f5e/opencv_python-4.1.1.26-cp37-cp37m-win_amd64.w hl (39.0MB) Requirement already satisfied: numpy>=1.14.5 in c:\users\hafeezulkareem\anaconda3\l ib\site-packages (from opencv-python==4.1.1.26) (1.16.2) Installing collected packages: opencv-python Successfully installed opencv-python-4.1.1.26Adding Two ImagesWe need two images for the addition. We have a method called cv2.add(image_one, image_two) to perform addition. It's very hand method. The sizes of the two images must be the same. ... Read More

872 Views
In this tutorial, we are going to work with the audio files. We will breakdown the audio into chunks to recognize the content in it. We will store the content of the audio files in text files as well. Install the following modules using the below commands.pip install pydubIf you run the above command, you will get the following successful messageCollecting pydub Downloading https://files.pythonhosted.org/packages/79/db/eaf620b73a1eec3c8c6f8f5 b0b236a50f9da88ad57802154b7ba7664d0b8/pydub-0.23.1-py2.py3-none-any.whl Installing collected packages: pydub Successfully installed pydub-0.23.1pip install audioreadIf you run the above command, you will get the following successful message.Collecting audioread Downloading https://files.pythonhosted.org/packages/2e/0b/940ea7861e0e9049f09dcfd 72a90c9ae55f697c17c299a323f0148f913d2/audioread-2.1.8.tar.gz Building wheels for collected packages: audioread Building wheel for audioread ... Read More

433 Views
In this tutorial, we are going to learn about the Barnsley Fern, which is created by Michael Barnsley. The features of Barnsley Fern is similar to the fern shape. It is created by iterating over the four mathematical equations known as Iterated Function System(IFS). The transformation has the following formula.f(x, y)=$$\begin{bmatrix}a & b \c & d \end{bmatrix}\begin{bmatrix}x \y \end{bmatrix}+\begin{bmatrix}e \f \end{bmatrix}$$Source − WikipediaThe values of the variables are −Source − WikipediaThe four equation that Barnsley Fern proposed are −Source − WikipediaNow, we will see code to create the fern shape in Python.Example# importing matplotlib module for the plot import matplotlib.pyplot ... Read More

526 Views
In this tutorial, we are going to write a solution for a challenge.ChallengeWe have to generate a random set of basic arithmetic operations. The user will give the number of questions, and we have to generate questions. After every question, the user will answer it. At the end of the program, we have to give the score. Let's try it.Example# importing random and operator modules import random import operator # main function # taking number of questions that we have to generate def main(n): print("Welcome to the quizYou should answer floats upto 2 decimals") # initialising score to ... Read More

333 Views
Python is a computer programming language that is frequently used to create websites and software, automate tasks, and analyze data. Python is a general-purpose programming language, which means it can be used to create a wide range of programs and is not specialized for any particular problem. This versatility, combined with its ease of use for beginners, has made it one of the most widely used programming languages today It is regarded as the best language for beginners, to begin with. Nowadays, almost every company that has an application, a website, or any computer-driven hardware requires programming. Needless to say, ... Read More

358 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

205 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