Python is a popular programming language used to develop websites, analyze data, and automate tasks. These various Python articles provide information on courses, resources, books, and communities to help you learn this coding language. There is also a handy glossary of Python terminology, quizzes and exercises, and specific resources for various career paths.
Learn Python
Python Move File: A Complete Guide
The Python shutil.move() method moves a file to another location on your computer. This method is part of the shutil model, which you must import before using this method. Moving files is a common operation in Python programs. For instance,…
Python Shuffle List: A Step-By-Step Guide
The Python random.shuffle() method changes the order of the items in a list at random. Combined with indexing, this method is useful for selecting a random item from a list. The random.shuffle() method accepts one argument: the list you want…
Python Power: A Step-By-Step Guide
The ** operator and the pow() function calculate the power of a number in Python. The ** operator raises the number on the left to the power of the number on the right. The pow() function raises the first parameter…
Python Ord: A Step-By-Step Guide
The Python ord() method converts a character into its Unicode code. The ord() method takes one argument: a string containing a single Unicode character. This method returns an integer that represents that character in Unicode. You may encounter a situation…
How to Write a Python Insertion Sort
The Python insertion sort works like sorting game cards. To use the insertion sort, you create two lists: a sorted and unsorted list. You compare each item in the unsorted list until you sort that item. The insertion sort is…
How to Use the Python Modulo Operator
The Python modulo operator calculates the remainder of dividing two values. This operator is represented by the percentage sign (%). The syntax for the modulo operator is: number1 % number2. The first number is divided by the second then the…
How to Copy a List in Python
You can copy a list in Python using the copy() method, slicing, the list() method, and a list comprehension. The copy() method is the most direct way of copying a Python list. When you’re working with a list in Python,…
Selection Sort Python: A Guide
A Python selection sort divides a list into two small lists. One list represents the sorted elements. The other list contains the unsorted elements. The selection sort finds the smallest or highest values in each iteration and moves those values…
Python Create Directory: A How-To Guide
The Python os.mkdir() method creates a blank directory on your file system. You cannot use this method to create a folder in a folder that does not exist. The os.mkdirs() method recursively creates a blank directory. Files let you store…
What is __init__.py? : A guide
The __init__.py file indicates that the files in a folder are part of a Python package. Without an __init__.py file, you cannot import files from another directory in a Python project. How to Use the Python __init__.py File While taking…
Python Rename File: A Step-By-Step Guide
The Python os.rename() method changes the name of a file. os.rename() accepts two arguments: the path of the old file and the path of the new file. The new file path should end in a different file name. When you’re…
How to Use the Python not Keyword
The Python not keyword returns True if a value is equal to False and vice versa. This keyword inverts the value of a Boolean. The not keyword can be used with an if statement to check if a value is…
Python Strings: One of Python’s Most Popular Data Types
Strings are one of the most popular data types in Python. A string is, at a high level, an object consisting of a sequence of characters. A character is a symbol — the English language, for instance, has 26 characters…
Python Flatten List: A How-To Guide
Flattening a list refers to the process of removing a dimension from a list. A dimension refers to an additional co-ordinate needed to locate an item in a list. You can flatten a Python list using a list comprehension, a…
Python Absolute Value: A Step-By-Step Guide
The Python abs() method returns the absolute value of a number. The absolute value of a number is the number’s distance from 0. This makes any negative number positive, while positive numbers are unaffected. For example, abs(-9) would return 9,…
Python Remove Character from String: A Guide
You can remove a character from a Python string using replace() or translate(). Both these methods replace a character or string with a given value. If an empty string is specified, the character or string you select is removed from…
Python: Return Multiple Values from a Function
You can return multiple values by bundling those values into a dictionary, tuple, or a list. These data types let you store multiple similar values. You can extract individual values from them in your main program. Or, you can pass…
Python += Operator: A Guide
The Python += operator lets you add two values together and assign the resultant value to a variable. This operator is often referred to as the addition assignment operator. It is shorter than adding two numbers together and then assigning…
Do While Python: A Step-By-Step Guide
The do while Python loop executes a block of code repeatedly while a boolean condition remains true. The Python syntax for while loops is while[condition]. A "do while" loop is called a while loop in Python. Most programming languages include…
How to Code a Python QuickSort
A Python QuickSort selects a pivot element and splits the elements of an array into two new arrays. Numbers higher than the pivot go into one array; numbers lower than the pivot go into another. Each array is sorted and…
Python Dictionary: A Guide for Beginners
A Python dictionary stores data in key-value pairs. A key is a label for a value. Dictionaries are declared as a set of keys and values between a pair of curly brackets. The syntax for a key and value is:…
Python KeyError: A Beginner’s Guide
A Python KeyError is raised when you try to access an item in a dictionary that does not exist. You can fix this error by modifying your program to select an item from a dictionary that does exist. Or you…
Python for Loop: The Complete Guide
A Python for loop iterates over an object until that object is complete. For instance, you can iterate over the contents of a list or a string. The for loop uses the syntax: for item in object, where "object" is…
How to Write Python Functions
A Python function is a group of code. To run the code in a function, you must call the function. A function can be called from anywhere after the function is defined. Functions can return a value using a return…
Python Comment: A Step-By-Step Guide
A Python comment is a line of text in a program that is not executed by the interpreter. Comments are used during debugging to identify issues and to explain code. Comments start with a hash character (#). How to Comment…
Python Import Statements: A Guide
The Python import statement lets you import a module into your code. A module is a file that contains functions and values that you can reference from your program. The import statement syntax is: import modulename. Python is accompanied by…
Python Variables: A How-To Guide
A Python variable stores a value in a program. Variables have two parts: a label and a value. These two parts are separated by an equals sign (=). You can use the label to refer to the value assigned to…
Python Random Choice: A How-To Guide
The Python random.choice() method returns an element selected at random from a list. random.choice() works on a list with items in any data type. random.choice() accepts one argument: the list from which you want to select an item. You may…
Python Pop: A Step-By-Step Guide
The Python pop() method removes an item at a specified index value from a list. This method returns the item you have removed so you know what modification has been made to your list. pop() accepts one argument: the index…
Python Find: A Guide
The Python find() method locates the index position at which the first instance of a string occurs in another string. find() returns -1 if a value cannot be found. Otherwise, it returns the starting index position of the value for…