Practical solutions

Python How-To's How-To Guides

Solve the problem. Keep building. The collection of Python-related howtos

Find the answer you need

Browse practical solutions, grouped by the task you're working on.

__COUNT__ entries on this page

How to End Program in PythonIn Python, many built-in functions like quit(), exit(), sys.exit(), and os.exit() are used to end Python program. How to Randomly Select Item From a List in PythonThis article demonstrates how to randomly select a item from a list in Python How to Change Working Directory in PythonIt demonstrates how to change the working directory in Python. How to Print to stderr in PythonThis article provides an in-depth exploration of stderr in Python, emphasizing its significance alongside the more familiar standard output (stdout). It presents various methods for printing to stderr, encompassing the sys.stderr.write() function, the print() function with a file parameter, and the robust capabilities offered by Python's logging module. How to Unzip Files in PythonIn Python, files can be extracted or unzipped using Python's inbuilt module ZipFile. This module provides different functions to extract files from the zip folder in the same or different directory. How to Copy a Dictionary in PythonIt demonstrates how to copy a dictionary in Python, based on value or address. How to Check if a Value Is in a Dictionary in PythonIt demonstrates how to check whether a value exists in the Python dictionary or not. How to Reverse a Dictionary in PythonIt demonstrates how to invert the key-value pair of a dictionary in Python How to Reverse a List in PythonIt demonstrates how to reverse a list in Python How to Do Exponents in PythonIt demonstrates how to do powers and exponent in Python How to Check File Size in PythonIn Python, the file size can be determined using the os module functions. We can use pathlib library, os.path(), stat function, and file object method to do this. How to Write a List to a File With PythonThis tutorial clarifies how to write a list to a file in Python. How to Find Maximum Value in a List in PythonIt demonstrates how to find maximum value in a list in Python How to Compare Two Dates in PythonThere are 4 main methods that can be used to compare dates in Python. How to Add Days to a Date in PythonThe tutorial describes how to add days to a date in Python. How to Subtract Datetime in PythonIt introducess how to perform datetime subtraction in Python How to Get File Extension in PythonIt demonstrates how to get the file extension in Python. How to Convert Hex to Byte in PythonThis tutorial introduces how to convert hexadecimal values into a byte literal in Python. How to Convert Epoch to Datetime in PythonIt introduces how to convert epoch to date time in Python How to Convert Byte to Hex in PythonIt introduces how to convert byte to hex in Python How to Append to a Tuple in PythonIt demonstrates how to append to a tuple in Python How to Find String in File using PythonThe tutorial demonstrates how to search for a string in a text file in Python. How to Write Dictionary Into CSV in PythonIt demonstrates how to write a dictionary into csv file in Python How to Pretty Print a Dictionary in PythonIt demonstrates how to pretty print a dictionary in Python