Alekhya Nagulavancha

Alekhya Nagulavancha

11 Articles Published

Articles by Alekhya Nagulavancha

11 articles

Python Program to calculate the area of the rhombus

Alekhya Nagulavancha
Alekhya Nagulavancha
Updated on 26-Mar-2026 3K+ Views

A rhombus is a four-sided polygon with all equal edges and perpendicular diagonals. It is a special type of parallelogram where opposite sides are equal and parallel. p q equal sides The area of a rhombus is calculated using its diagonals, as they form four triangles within the figure. The mathematical formula is − Area = (p × q) / 2 Where p and q are the lengths of the diagonals. Input Output Scenarios Let us look ...

Read More

Python Program to calculate the volume and area of Sphere

Alekhya Nagulavancha
Alekhya Nagulavancha
Updated on 26-Mar-2026 7K+ Views

A sphere is a three-dimensional geometric figure where every point on its surface is equidistant from the center. We can calculate both the surface area and volume of spheres using mathematical formulas. r Solid Sphere R r Hollow Sphere Formulas The mathematical formulas for calculating sphere properties are − Surface Area ...

Read More

Python Program to calculate the volume and area of Cone

Alekhya Nagulavancha
Alekhya Nagulavancha
Updated on 26-Mar-2026 5K+ Views

A cone is a three-dimensional figure formed by connecting infinite line segments from a common point (apex) to all points on a circular base. The cone has three key measurements: radius of the circular base, height, and lateral height (slant height). The height is measured from the apex to the center of the circular base, while the lateral height (or slant height) is the distance from the apex to any point on the circumference of the base. ...

Read More

Python Program to calculate the volume and area of the Cylinder

Alekhya Nagulavancha
Alekhya Nagulavancha
Updated on 26-Mar-2026 3K+ Views

In this article, we will look into a python program to calculate the volume and area of a cylinder. A cylinder is defined as a 3D object that has two circles connected with a rectangular surface. The special thing about a cylinder is that even though it is measured using just two dimensions, i.e. the height and radius, the cylinder is considered a three-dimensional figure as it is measured in xyz coordinate axes. ...

Read More

Python Program to calculate the volume of Cube

Alekhya Nagulavancha
Alekhya Nagulavancha
Updated on 26-Mar-2026 7K+ Views

A cube is a three-dimensional solid figure with six faces, twelve edges and eight vertices. This geometrical figure has equal sized edges, hence making all its dimensions − length, width and height − equal. The idea of calculating the volume of a cube can be understood in a simple way. Consider a real-time situation where a person is moving houses. Suppose they use a hollow cube shaped cardboard box to place their things in it, the amount of space present to fill it up is defined as the volume. ...

Read More

Multi-Line Statements in Python

Alekhya Nagulavancha
Alekhya Nagulavancha
Updated on 25-Mar-2026 7K+ Views

In Python, statements are instructions given to the interpreter to understand and execute. These statements are usually written in a single line of code, but Python provides several ways to write statements across multiple lines for better readability. There are two types of statements in Python: assignment statements and expression statements. Both can be broken into multiple lines, and the Python interpreter will understand them correctly. There are various ways to structure multi-line statements in Python ? Using the backslash (\) operator Using parentheses () Using curly braces {} Using square brackets [] Using ...

Read More

How can I iterate over files in a given directory in Python?

Alekhya Nagulavancha
Alekhya Nagulavancha
Updated on 24-Mar-2026 11K+ Views

Iterating over files in a given directory helps to perform tasks such as finding files that match certain criteria or counting the number of files in a directory. Python provides several methods to walk through all the existing files in a directory ? os.listdir() method os.walk() method os.scandir() method Using pathlib module glob.iglob() method In this article, we will explore all these methods for iterating over files in a given directory in Python. Using os.listdir() Method The os.listdir() method ...

Read More

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

Alekhya Nagulavancha
Alekhya Nagulavancha
Updated on 24-Mar-2026 19K+ 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 defined as given below ? ./my_directory/my_file The directory, sub-directory and the file are all separated using the "/" separator in the path. Therefore, to get current file's full path, you can use the os.path.abspath() function. If you want only the directory path, you can call ...

Read More

How to calculate a directory size using Python?

Alekhya Nagulavancha
Alekhya Nagulavancha
Updated on 24-Mar-2026 8K+ Views

A directory is simply defined as a collection of subdirectories and files. 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 the "root" directory. Calculating the total size of a directory, including all its files and subdirectories, is a common task in Python, especially when dealing with disk usage monitoring, backup management, or cleaning up storage. Python provides multiple ways to accomplish this efficiently using built-in modules such as os and pathlib. In this article, we ...

Read More

How to scan through a directory recursively in Python?

Alekhya Nagulavancha
Alekhya Nagulavancha
Updated on 24-Mar-2026 15K+ Views

A directory is simply defined as a collection of subdirectories and files. A directory hierarchy is constructed by organizing all the files and subdirectories within a main directory, also known as the root directory. These subdirectories are separated using a / operator in a directory hierarchy. In Python, we have different methods to scan through a directory recursively. In this article we are going to see about each method: Using os.walk() method Using glob.glob() method Using os.listdir() method with recursion Note: The directories ...

Read More
Showing 1–10 of 11 articles
« Prev 1 2 Next »
Advertisements