
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
Tkinter is the GUI building library of python. In this article we will see how we can create a collapsible pane. They are usefult when we have some large amount of data to be displayed over a GUI canvas but we do not want to be displayed always. It is made collapsible so that it can be displayed as and when needed.The below program creates the collapsible pane where we see the result both after expanding and contracting the arrow. The code comments indicate the approach we take at each step.Examplefrom tkinter import * import tkinter as tk from tkinter ... Read More

1K+ Views
Many times we use a method called data smoothing to make the data proper and qualitative for statistical analysis. During the smoking process we define a range also called bin and any data value within the range is made to fit into the bin. This is called the binning method. Below is an example of binning. Then we will see how we can achieve the binning method using a Python program.Binning ExampleLet’s take a series of numbers. Find the maximum and minimum values. Decide on the number of bins we need depending on how many data points the analysis needs. ... Read More

2K+ Views
The ASCII text can be used to display many stylish texts by using the module pyfiglet. After installing this module we can use it to control the font that can be used to display the result. In the below program we see various results by choosing various font types.Example# import pyfiglet module import pyfiglet #Text in default font out = pyfiglet.figlet_format("Point") print(out)OutputRunning the above code gives us the following result −Example# import pyfiglet module import pyfiglet #Text in slant font out = pyfiglet.figlet_format("Point", font="slant") print(out)OutputRunning the above code gives us the following result −Example# import pyfiglet module import pyfiglet #Text ... Read More

1K+ Views
In this article, we will learn how to add a constant K value to each element in a Python list of integers. A list is a data type in Python that stores a sequence of items separated by commas, like this − List = [item1, item2, item3…] Suppose we have a list of integers called "a" and a constant value "k." We need to add this "k" to each item in the "a" list. For example − Input: a = [5, 10, 15, 20] k = 5 Output: #On adding 5 to each element of the ... Read More

389 Views
By adding strings in python we just concatenate them to get a new string. This is useful in many scenarios like text analytics etc. Below are the two approaches we consider for this task.Using += OperatorThe + operator can be used for strings in a similar was as it is for numbers. The only difference being, in case of strings the concatenation happens and not a numeric addition.Example Live Demos1 = "What a beautiful " s2 = "flower " print("Given string s1 : " + str(s1)) print("Given string s2 : " + str(s2)) #Using += operator res1 = s1+s2 print("result ... Read More

278 Views
We may sometimes need to append zeros as string to various data elements in python. There may the reason for formatting and nice representation or there may be the reason for some calculations where these values will act as input. Below are the methods which we will use for this purpose.Using format()Here we take a DataFrame and apply the format function to the column wher we need to append the zeros as strings. The lambda method is used to apply the function repeatedly.Exampleimport pandas as pd string = {'Column' : ['HOPE', 'FOR', 'THE', 'BEST']} dataframe=pd.DataFrame(string) print("given column is ") print(dataframe) ... Read More

602 Views
Lists can be nested. Which means we have smaller lists as elements inside a bigger list. In this article we solve the challenge of adding the elements of a simple list to the elements of a nested list. If the length of the lists are different then the length of the smaller list becomes the maximum length of the resulting list.Below are the various methods to accomplish this.Using for LoopIn this method, we take the length of the smaller list and loop through the elements of this list adding it to the elements of the bigger list. Here we use ... Read More

2K+ Views
Tkinter, which is the GUI library for python programming has a feature to add images to the GUI buttons. This is useful for users to remember the symbols in the GUI rather than the text in the GUI. In the below Tkinter program we show how we can add an image to a GUI button. The photoimage method from the imageKT module is used. We mention the local path to the image file.Examplefrom tkinter import * from PIL import ImageTk ,Image base = Tk() base.title('Start Button') img=ImageTk.PhotoImage(Image.open ("D:\button.jpg")) lab=Label(image=img) lab.pack() button=Button(base, text='exit', command=base.quit) button.pack() base.mainloop()OutputRunning the above ... Read More

2K+ Views
The CSV file or comma separated values file are one of the most widely used flat files to store and hare data across platforms. The columns are separated by comma and there is optional header row also which will indicate the name of each column. Python can read the CSV files using many modules. In this article we will see how the CSV library in python can be used to read and write a CSV file. We can also see the pandas library onl to read the CSV file.Reading CSV file using csv moduleWe can get the CSV file from ... Read More

2K+ Views
Python language is used extensively for web programming. When we browser website we use the web address which is also known as URL or uniform resource locator. Python has inbuilt materials which can handle the calls to the URL as well as pass the result that comes out of visiting the URL. In this article we will see a module named as urllib. We will also see the various functions present in this module which help in getting the result from the URL.Installing urllibTo install urllib in the python environment, we use the below command using pip.pip install urllibRunning the ... Read More