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 String Strip: How To Use Python Strip
Python strip functions remove characters or white spaces from the beginning or end of a string. The strip functions are strip(), lstrip(), and rstrip(). They remove characters from both ends of a string, the beginning only, and the end only.…
Python Return: A Step-By-Step Guide
The Python return statement instructs Python to continue executing a main program. You can use the return statement to send a value back to the main program, such as a string or a list. Functions are blocks of instructions that…
Python Dictionary Get: Step-By-Step Guide
The Python dictionary get() method returns the value associated with a specific key. get() accepts two arguments: the key for which you want to search and a default value that is returned if the key is not found. Retrieving a…
Python Round: A Step-By-Step Guide
The Python round() method rounds a number to a specified number of decimal places. By default, round() rounds a number to zero decimal places. round() is useful if you want to work with numbers with a certain precision. You may…
Python Bubble Sort: A How-To Guide
A Python bubble sort goes through a list and compares elements next to each other. If an element on the right is greater than one on the left, the elements are swapped. This happens until the list is sorted. Do…
Python args and kwargs: A Guide
Both Python *args and **kwargs let you pass a variable number of arguments into a function. *args arguments have no keywords whereas **kwargs arguments each are associated with a keyword. Traditionally, when you’re working with functions in Python, you need…
Python Main Functions: A How-To Guide
The Python main() method contains the methods and code you want to execute in a main program. It is not necessary because Python runs code line-by-line but the main() method helps make code more readable. How to Use Python Main…
Python Try Except: A Step-By-Step Guide
The Python try...except statement catches an exception. It is used to test code for an error which is written in the "try" statement. If an error is encountered, the contents of the "except" block are run. How to Use Try…
Python Super: A How-To Guide
The Python super() method lets you access methods from a parent class from within a child class. This helps reduce repetition in your code. super() does not accept any arguments. One core feature of object-oriented programming languages like Python is…
A Step-By-Step Guide to Python Count
The Python count() method calculates how many times a particular element appears in a list or a string. count() accepts one argument: the value for which you want to search in the list. The count() method is appended to the…
Python Priority Queue: A Guide
Python Priority Queue: A Guide A Python priority queue stores data in a particular order. There are two ways to implement a priority queue in Python: using the queue class and using the heapq module. You may want to order…
Iterate Through Dictionary Python: Step-By-Step Guide
The items() method, the keys() method, and the values() method return values you can use to iterate through a dictionary in Python. items() returns both the keys and values in a Python dictionary. keys() returns the keys in a dictionary.…
Python f Strings: The Ultimate Guide
Python f strings embed expressions into a string. An expression may be the contents of a variable or the result of a mathematical calculation, or another Python value. f strings are distinguished from regular strings as the letter f comes…
Python: Check If a File Exists
The Python os.path.isdir() method checks if a directory exists. os.path.isfile() checks whether a file exists. Both of these methods are part of the Python os library. Checking whether a certain file or directory exists has a number of uses in…
Python Min and Max: The Ultimate Guide
The Python max() function is used to find the largest value in a list of values. The Python min() function is used to find the lowest value in a list. The list of values can contain either strings or numbers.…
Python os.path.join: A Beginner’s Guide
The Python os.path.join method combines one or more path names into a single path. This method is often used with os methods like os.walk() to create the final path for a file or folder. os.path.join() automatically adds any required forward…
How to Declare a List in Python
To initialize a list in Python assign one with square brackets, initialize with the list() function, create an empty list with multiplication, or use a list comprehension. The most common way to declare a list in Python is to use…
How to Remove Duplicates from a List in Python
You can remove duplicates from a Python using the dict.fromkeys(), which generates a dictionary that removes any duplicate values. You can also convert a list to a set. You must convert the dictionary or set back into a list to…
Python Sum: A Step-By-Step Guide
The Python sum() function calculates the total of all numerical values in an iterable. sum() works with both integers and floating-point numbers. The sum() function has an optional parameter to add a number to the total. alculating the sum of…
Python Concatenate Strings: Step-By-Step Guide
Python string concatenation is the process of merging two or more strings. The + operator adds a string to another string. % lets you insert a string into another string value. Both operators are used to concatenate strings in Python.…
Python List Files in a Directory: Step-By-Step Guide
The Python os library is used to list the files in a directory. The Python os.listdir() method returns a list of every file and folder in a directory. os.walk() function returns a list of every file in an entire file…
Python Ceil and Floor: A Step-By-Step Guide
The Python ceil() function rounds a number up to the nearest integer, or whole number. Python floor() rounds decimals down to the nearest whole number. Both of these functions are part of the math Python library. When programming in Python,…
Python Reverse String: A Step-By-Step Guide
You can reverse a string in Python using slicing or the reversed() method. A recursive function that reads each character in a string and reverses the entire string is another common way to reverse a string. There is no function…
Python Lowercase: A Step-By-Step Guide
The Python lower() function converts a string to all lowercase. The Python isLower() method will check if the alphabetical characters in a string are all lowercase and return True or False. The lower() and isLower() functions are useful for fields…
Python Nested Dictionary: A How-To Guide
A Python nested dictionary is a dictionary within another dictionary. This lets you store data using the key-value mapping structure within an existing dictionary. When you’re working with dictionaries in Python, you may encounter a situation where a dictionary contains…
Python AttributeError: A How-To Guide
Attributes are values or functions associated with an object, a data type, or a class. If you call an attribute on a value whose data type or class does not support that attribute, you’ll encounter an AttributeError. This guide discusses…
Python Delete File: A Step-By-Step Guide
You can delete files from your computer using Python. The os.remove() method deletes single Python files. os.rmdir() removes a file or a directory. The shutil.rmtree() method will delete a directory and the files contained in it. Developers use files in…
Python Optional Arguments: A How-To Guide
A Python optional argument is a type of argument with a default value. You can assign an optional argument using the assignment operator in a function definition or using the Python **kwargs statement. There are two types of arguments a…
Python Ternary Operator: A How-To Guide
The Python ternary operator lets you evaluate whether a condition is true or false. The ternary operator takes up one line of code, which means it is shorter and more concise than a full if...else statement. Conditional statements, such as…
Binary Search Python: A Step-by-Step Guide
A Python binary search finds the position of an item in a sorted array. It divides a list in half. If a specified value is higher than the middle number, the search focuses on the right of the list. Otherwise,…