
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

8K+ Views
Everything in Python is an object including classes. All classes are instances of a class called "type".The type object is also an instance of type class. You can inspect the inheritance hierarchy of class by examining the __bases__ attribute of a class object. type() method returns class type of the argument(object) passed as parameter.If single argument type(obj) is passed to type method, it returns the type of given object. If three arguments type(name, bases, dict) is passed, it returns a new type object.Using type()Let’s look at the classes for the most used data types. In the below program we initialize ... Read More

2K+ Views
Code objects are a low-level detail of the CPython implementation. Each one represents a chunk of executable code that hasn’t yet been bound into a function. Though code objects represent some piece of executable code, they are not, by themselves, directly callable. To execute a code object, you must use the exec keyword.In the below example we see how the code objects are created for a given piece of code and what are the various attributes associated with hat code object.Example Live Democode_str = """ print("Hello Code Objects") """ # Create the code object code_obj = compile(code_str, '', 'exec') # get ... Read More

155 Views
If two variables are of the same data types and not iterators like list and dictionary etc, then the expressions a += b is same as a =+b gives the same result. But when n iterator is involved we can not always expect the same. Below is one of such scenario.Case of a = a +bHere we can see when we apply the expression to a list and a string expecting they will get merged, we get back an error.Examplex ='Hello ' z_list = [1, 2, 3] z_list = z_list + x print(z_list)OutputRunning the above code gives us the following ... Read More

479 Views
As we write python programs we need various other modules to leverage their functions, classes etc. in our current program. We can import those modules at the runtime using the import function. Though you can also import named modules at the beginning of the code, you may need the module temporarily for only few lines of code or you want to make the copy of an object from the module and modify and use it.SyntaxThe syntax of the __import__() function is −__import__(name, globals=None, locals=None, fromlist=(), level=0) Where name - the name of the module you want to import globals and ... Read More

386 Views
Pygame is a multimedia library for Python for making games and multimedia applications. In this article we will see how to use the pygame module to draws many different shapes on the screen taking into consideration, its height, width and position in the pygame window.In the below program we initialize the pygame moduel and then deifne the colour and dimension for the image. Next we add the different shapes as per the syntax and carefully mention the arguments to the darw functions so that the images do not overlap with each other. The screen.blit function paints the screen while the ... Read More

818 Views
Pygame is a multimedia library for Python for making games and multimedia applications. In this article we will see how to use the pygame module to get customized font and text on the screen taking into consideration, its height, width, and position in the pygame window.In the below program we initialize the pygame module and then define the mode and the caption for the image. Next we add the font text and define the coordinates for the font. The screen.blit function paints the screen while the while loop keeps listening the end of the game is clicked.Exampleimport pygame import sys ... Read More

1K+ Views
Pygame is a multimedia library for Python for making games and multimedia applications. In this article we will see how to use the pygame module to paint a picture on the screen taking into consideration, its height, width and position in the pygame window.In the below program we initialize the pygame module and then define the mode and the caption for the image. Next we load the image and define the coordinates. The screen.blit function paints the screen while the while loop keeps listening the end of the game is clicked.Exampleimport pygame pygame.init() w = 300; h = 300 screen ... Read More

908 Views
Pandas is one of the most popular python library for data analysis and data wrangling. In this article we will see how we can create a pandas dataframe and then delete some selective rows ort columns from this data frame.Deleting roewsIn the below example we have the iris.csv file which is read into a data frame. We first have a look at the existing data frame and then apply the drop function to the index column by supplying the value we want to drop. As we can see at the bottom of the result set the number of rows has ... Read More

297 Views
Bokeh is an python data visualization library for web browsers. It czncreate elegant, concise construction of versatile graphics. It is used to quickly and easily make interactive plots, dashboards, and data applications. In this article we will see how we can create various types of basic graphs using Bokeh.Plotting LinesWe can create a line plot by using the x and y coordinates of the points in it as two lists. We directly display the output in the browser by specifying the height and width of the figure. We can also supply additional parameters like width of the line and colour ... Read More

360 Views
The Sklearn python library does provide sample data sets which can be used tocreate various graph plots. The usefulness of these datasets is in creating sample graphs and charts and predicting the behavior of the graph as the values changes. Also you can work on other parameters like deciding on the colours and axes etc on this sample graphs before using the actual data set.Using make_blobsIn the below example we use the sklearn library along with the matplotlib to create a scatter plot with a specific style. We choose a sample of 200 data points and also select the colour ... Read More