Alekhya Nagulavancha has Published 29 Articles

How to find if a directory exists in Python?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 24-Feb-2023 12:13:45

5K+ Views

Directory creation is a common task for computer users. You might need to create a directory to store some files, or to place some new files inside an existing directory. In this article, you will learn how to find if a directory already exists in Python or not. A directory ... Read More

How to print full path of current file's directory in Python?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 24-Feb-2023 12:09:56

15K+ Views

The path of a current file is defined with the help of directory hierarchy; and it contains the backtracked path from the current file to the root directory this file is present in. For instance, consider a file “my_file” belongs to a directory “my_directory”, the path for this file is ... Read More

How to scan through a directory recursively in Python?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 24-Feb-2023 12:08:19

8K+ Views

A directory is simply defined as a collection of subdirectories and single files; or either one of them. A directory hierarchy is constructed by organizing all the files and subdirectories within a main directory, also known as “root” directory. These subdirectories are separated using a “/” operator in a directory ... Read More

How to calculate a directory size using Python?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 24-Feb-2023 12:04:36

5K+ Views

A directory is simply defined as a collection of subdirectories and single files; or either one of them. These subdirectories are separated using a “/” operator in a directory hierarchy. A directory hierarchy is constructed by organizing all the files and subdirectories within a main directory, also known as “root” ... Read More

How to print the Python Exception/Error Hierarchy?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 24-Feb-2023 11:18:30

3K+ Views

We will learn about what an exception is before learning how to print python exceptions. An exception occurs when a program fails to execute in the direction it was intended to be. Python throws exceptions when unexpected errors or events occur. It is common for exceptions to be both valid ... Read More

How to pass keyword parameters to a function in Python?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 24-Feb-2023 11:14:02

4K+ Views

In Python, functions are usually called by passing none, one or more arguments to it. There are two types of arguments that can be used − Positional arguments Keyword arguments. Positional arguments depend on the order they are passed to a function; they are the more common type ... Read More

How to ignore an exception and proceed in Python?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 22-Feb-2023 17:56:49

22K+ Views

An exception is an unexpected error or event that occurs during the execution of program. The difference between an error and an exception in a program is that, when an exception is encountered, the program deflects from its original course of execution whereas when an error occurs, the program is ... Read More

How to handle a python exception within a loop?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 22-Feb-2023 17:54:33

9K+ Views

The looping technique in Python transforms complex problems into simple ones. It allows us to change the flow of the program so that instead of writing the same code over and over, we can repeat it a limited number of times until a certain condition is satisfied. For example, if ... Read More

How to call a function with argument list in Python?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 22-Feb-2023 17:47:07

3K+ Views

The purpose of a function is to perform a specific task using code blocks. In programming, functions save time by eliminating unnecessary and excessive copying and pasting of code. Hence, a function will be of great use if there is a common action that needs to be performed in different ... Read More

How do I check if a Python variable exists?

Alekhya Nagulavancha

Alekhya Nagulavancha

Updated on 22-Feb-2023 17:43:21

14K+ Views

Variables are defined as the containers used to store some data. They represent a memory location. Any type of data or value can be stored in a variable in Python, including integers, strings, float, Boolean etc. In Python, a variable's data type does not need to be specified when it ... Read More

Advertisements