Category Built-in Methods

How to Open Files in Python

How to Open Files in Python

To read information saved in a file, your Python program first needs to open it. Python’s built-in open() function opens a path and returns a file object your program can use to read or write data. This article shows how…

Lowest Python Values with min()

Lowest Python Values with min()

Comparing a few Python values or finding the smallest item in a list calls for a way to select the minimum. min() returns the lowest item from an iterable or from separate arguments. This article explains both ways to use…

Convert String to Int in Python

Convert String to Int Python with int() and str()

A Python program may receive digits as text but need a numeric value for whole-number arithmetic. The built-in int() parses integer text into an integer, while str() turns a number into text again. I’ll show how int() converts integer text,…

Python xrange: Meaning and Migration

Python xrange: Meaning and Migration

Updating Python code that uses xrange() starts with knowing which Python version the code targets. In Python 2, xrange() provides an immutable integer sequence for loops, while Python 3 uses range() for that job. This article explains what xrange() did…