Category: Python Tutorials

Python programming, installation, tutorials, errors, examples, how to guides for beginners

Resize Image keeping aspect ratio – Python PIL Image Module

Below Python code resizes an image keeping it’s aspect ratio using PIL library Image Module. The above code is tested on Windows 10 PC using PyCharm 2019.3.3 In the code, we have set the height of the image to 900 Percentage of height of the resized image calculation proportional width value calculation using below formula […]

Python Pillow (PIL) Tutorial [Installation and Examples]

Python Pillow Pillow is a Python Imaging Library (called as PIL), which supports opening, manipulating (filtering, enhancing, masking, watermarking, resizing etc) and saving of images. The latest version can identify and read more than 30 image formats. Write support is intentionally restricted to few image formats. Installing Python Pillow on Windows To install Python Pillow […]

Top Rated Python Books on Amazon 2020

1. Python Crash Course: A Hands-on, Project based Introduction To Programming This book is highly recommended by many verified purchasers on Amazon. They mentioned that it is a great book for beginners to learn Python. Below are some of their comments “Effective For Teaching The Basics” “From your first exception error to your first Hello […]

Python: Get last 4 characters of a string [one line code]

Python code to get last four characters of a string. This single line code, excluding string line, prints the last 4 characters of the string. Change the number to get more or less characters. Example string: GetHowStuff Expected Output (last 4 characters): tuff string=”GetHowStuff” #prints last 4 characters of the string print(string[-4:])

Python: Extract file name from URL path [with and without extension]

Python code to extract the file name from path or URL is explained below. Find the delimiter “/” position before the file name using   firstpos=path.rfind(“/”) Find the last position of the file name using lastpos=len(path) Extract the file name using path[firstpos+1:lastpos]. Add 1 to the first position to avoid extracting the delimeter “/”. Python code […]

Easiest ways to find the python version installed on Windows PC

find-python-version-using-powershell

This post teaches you how to find the python version installed on your Windows PC. I used windows 10 here. Related: Easy steps to install Python on Windows Method 1: Using Command Prompt Open command Prompt. Type CMD in Windows search bar and click on Command prompt in the search results. Type python and ENTER. […]

Simple steps to install/uninstall pygame on windows [using pip]

Below are the simple steps to install pygame on Windows Operating system. Steps to install Pygame Install Python on Windows if you have not installed it Goto download pygame Goto Navigation  -> click Download files Download the latest version of pygame source file (.tar.gz file) Download the pygame package by clicking on pygame.x.x.x.tar.gz file link (x.x.x […]