Change Current Working Directory In Python

Python provides different file and directory-related functions. While working with Python we may need to change the current working directory. Even we generally first check the current working directory and then change the current working directory accordingly. The os.chdir() method is used to change the current directory. In this tutorial, we examine how to change … Read more

Python os.mkdir() Method Tutorial

Python provides the mkdir() method in order to create directories in different operating systems like Linux, Windows, etc. The mkdir() method is provided via the os module. The mkdir() method creates the specified directory with its only name or using the full path. If the directory already exists the creation returns an error. os.mkdir() Syntax … Read more

Python Optional Arguments

Python provides functions and methods in order to execute tasks easily by just providing some arguments to them. Functions and methods generally require or accept some arguments for the task. As its name suggests the optional argument is simply free to provide or not provide. Generally, the optional argument value is set as a default … Read more

Import Math Module In Python

Python provides the math module for different mathematical functions. These functions can be used for calculations like ceil, factorial, floor, square root, mod, remainder, etc. The math module is a built-in module that is provided without any extra installation. The import math can be used to import math modules and use provided functions. In this … Read more

Check If Directory Exist In Python

Python provides different methods and ways in order to check if a directory exists. Generally, the os.path module is used to check the specified directory if it exists. In this tutorial, we examine all Python methods to check directory existence. Check If Directory Exists with os.path.exists() Method Python provides os.path for different operating-related methods. The … Read more

Python Order List (Ascending and Descending)

Python Order List (Ascending and Descending)

Python list is used to store multiple elements in a single variable. These items can be in different types like string, integer, etc. Sometimes we may want to sort them accordingly. We can sort them in ascending or descending ways by using the sort() provided by the list type. Order String List Ascending By default, … Read more

How To Convert Python Dictionary to JSON?

How To Convert Python Dictionary to JSON?

JSON is a very popular data structure used to store information in a human-readable and simple format. The long form for the JSON is the JavaScript Object Notation. The JSON format is generally used to store and transfer data between different systems and applications. As a popular programming language Python supports JSON. The Python Dictionary … Read more