Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Akshitha Mote
Page 2 of 4
Python program for removing n-th character from a string?
Removing the nth character from a string is a common string manipulation task in Python. We can accomplish this using several approaches: for loops, string slicing, or the replace() method. Let's explore each method with examples. Understanding the Problem When removing the nth character, remember that Python uses zero-based indexing. So the 1st character is at index 0, the 2nd character is at index 1, and so on. To remove the nth character, we target index n-1. Using a For Loop The for loop approach iterates through each character and skips the one at the target ...
Read MoreCreate Word Cloud using Python
A word cloud is a visual representation of text data, where the size of each word indicates its frequency or importance within the dataset. It helps us to identify the most common and important words in a text. It is typically used to describe/denote big data in a word. In this article, we will create a word cloud on the Python programming language, and the data is accessed from Wikipedia. Required Modules Following are the modules required to create a word cloud in Python − Install wordcloud Before installing the word cloud module, you have ...
Read MoreHow to convert HTML to PDF using Python
Converting HTML to PDF programmatically is a common requirement for generating reports, invoices, or documentation. Python provides several libraries for this task, with pdfkit being one of the most popular options as it leverages the powerful wkhtmltopdf engine. In this article, we will explore how to convert HTML files to PDF using Python with the pdfkit library. Prerequisites and Installation Step 1: Install pdfkit Library First, install the pdfkit library using pip − pip install pdfkit Step 2: Install wkhtmltopdf The pdfkit library requires wkhtmltopdf as its backend engine. Follow these ...
Read MorePython program for Modular Exponentiation
Modular exponentiation calculates (baseexponent) % modulo efficiently. This operation is fundamental in cryptography and number theory, involving three integers: base, exponent, and modulo. Syntax # Basic syntax result = (base ** exponent) % modulo # Using pow() function (recommended) result = pow(base, exponent, modulo) Basic Example Let's calculate (25) % 5 step by step ? base = 2 exponent = 5 modulo = 5 # Step by step calculation power_result = base ** exponent print(f"{base}^{exponent} = {power_result}") final_result = power_result % modulo print(f"{power_result} % {modulo} = {final_result}") ...
Read MorePython program to display Astrological sign or Zodiac sign for a given data of birth.
In this article, we'll learn how to determine the astrological sign or zodiac sign for a given date of birth. We'll compare the user's birthdate with predefined date ranges for each zodiac sign using Python programming logic. The 12 astrological sun signs, also known as zodiac signs, are based on specific periods throughout the year. Each sign corresponds to a particular range of dates ? Aries (March 21 − April 19) Taurus (April 20 − May 20) Gemini (May 21 − June 20) Cancer (June ...
Read MoreDifference between == and is operator in python.
In Python, the == and is operators are used for comparison, but they serve different purposes. The == operator checks for equality of values, which means it evaluates whether the values of two objects are the same. On the other hand, the is operator checks for identity, meaning it determines whether two variables point to the same object in memory. What Is the 'is' Operator? The Python is operator tests whether two variables refer to the same object in memory. If the variables refer to the same memory location, it returns True; otherwise, it returns False. This operator ...
Read MoreWhat is tilde (~) operator in Python?
In Python, the bitwise operator ~ (pronounced as tilde) is a complement operator. It takes one bit operand and returns its complement. If the operand is 1, it returns 0, and if it is 0, it returns 1. For example, consider the 4-bit binary number (1100)2. By performing the tilde operation, each bit is flipped and results in (0011)2. Syntax result = ~operand Tilde Operation on Decimal Numbers When we perform a tilde operation on decimal numbers, the following steps are involved − Convert the decimal number ...
Read MoreWhat is behavior of ++ and -- operators in Python?
In C/C++, Java, and other languages, ++ and -- operators are defined as increment and decrement operators. However, Python does not have these operators built into the language. Why Python Doesn't Support ++ and -- Operators In Python, objects are stored in memory and variables are just labels pointing to these objects. Numeric objects like integers and floats are immutable, meaning they cannot be modified in place. This design makes traditional increment and decrement operators unnecessary. Prefix ++ and -- Behavior When you use prefix ++ or -- operators in Python, they don't raise an error ...
Read MoreWhat is function of ^ operator in Python
In Python, the XOR operator is one of the bitwise operators and is represented by the caret symbol ^. It returns 0 if both operands are the same and 1 if the operands are different. Truth Table of XOR The following is the truth table of the XOR (exclusive OR) operator − A B ...
Read MoreDoes Python have a ternary conditional operator?
The Python ternary operator returns a value based on whether a condition is True or False. It is similar to an if-else statement but is expressed in a single line. For understanding the ternary operator, we need to have an idea about conditional statements. Let's have a basic understanding of the if-else statement. We will have an if block followed by an else block here. The if block is executed when the given condition is True, and the else block is executed if the given condition is False. The following is the basic syntax of the if-else statement ...
Read More