Python Programming Tips


How to Draw Diamond Shape ASCII Art in Python?

A common python programming problem given for beginners is to draw a diamond shape using star character as an ASCII art. For example, the following shows a diamond shape as ASCII art consisting of 9 rows, * *** ***** ******* ********* ******* ***** *** * Here is another diamond with 5 rows. * *** ***** […]

How to Create LRU Cache in Python

What is an LRU Cache? For any software product, application performance is one of the key quality attributes. One common technique used for improving performance of a software application is to use memory cache. A memory cache puts frequently used application data in the fast RAM of the computing device. Reading or writing data to […]

How to Draw Rectangles and Squares Using Python Turtle

Python’s turtle package can be used to draw various shapes on a canvas. Turtle allows the programmer to move a pen in a specified direction by specifying its heading and distance. Turtle has no built-in primitive for drawing a rectangle or square. However it is easy to create a function to draw a rectangle(or square) […]

How to Draw Circles Using Python Turtle

Python contains an interesting drawing module called Turtle. This module is available as part of the standard python distribution. Turtle consists of a number of graphics operations modelled after pen drawing. In this article I will show you how we can use the turtle commands to draw circle based shapes. How to Draw a Simple […]

How to Create Canvas Animation Using Tkinter

Tkinter is one of the most popular GUI toolkits available for python. It is available as part of the standard python installation. Hence you can use this package without installing any additional modules. Tkinter is a powerful GUI library and you can use it to build full fledged user interfaces or build simple desktop games. […]