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 karthikeya Boyini
Page 4 of 142
Read and Write to an excel file using Python openpyxl module
Python provides the openpyxl module for reading and writing Excel files. This powerful library allows you to create, modify, and extract data from Excel workbooks programmatically. Installation Install openpyxl using pip ? pip install openpyxl Getting Sheet Title When you create a new workbook, it comes with a default sheet ? import openpyxl my_wb = openpyxl.Workbook() my_sheet = my_wb.active my_sheet_title = my_sheet.title print("My sheet title: " + my_sheet_title) My sheet title: Sheet Changing Sheet Title You can customize the sheet name by modifying the ...
Read MoreDecimal Functions in Python
The Decimal module in Python provides precise decimal floating-point arithmetic, avoiding the common rounding errors that occur with standard floating-point numbers. This module is particularly useful for financial calculations where precision is critical. To use the Decimal module, you need to import it first ? import decimal Square Root and Exponential Functions The sqrt() method calculates the square root of a decimal number, while exp() returns ex for a given decimal value ? import decimal my_dec = decimal.Decimal(25.36) print(my_dec) print('Square Root is:', my_dec.sqrt()) print('e^x is:', my_dec.exp()) 25.3599999999999994315658113919198513031005859375 Square ...
Read MorePython Program to calculate the Round Trip Time (RTT)
Here we will see how Python can be used to get the Round Trip Time (RTT). The RTT is the time taken by the entire trip of a signal — the time between when a signal is sent and when the acknowledge signal is received. The RTT results vary based on different parameters like ? The data transfer rate of the sender's side. The nature of the transmission media. The actual distance between the sender and receiver. The number of nodes between sender and receiver. ...
Read MoreBirthday Reminder Application in Python
In this tutorial, we will create a birthday reminder application using Python that checks for birthdays on the current date and sends system notifications. Problem Statement Create a Python application that checks whether there is any birthday on the current day. If it's someone's birthday from our list, send a system notification with their name. We need a lookup file to store dates and names. Create a text file named birth_day_lookup.txt with this format ? 10-January John Doe 15-March Jane Smith 22-December Alice Johnson ...
Read MorePython program to calculate BMI(Body Mass Index) of your Body
Body Mass Index (BMI) is a measure used to determine whether a person has a healthy body weight for their height. The BMI formula is: BMI = weight (kg) / height² (m²). Algorithm Step 1: Input height in meters and weight in kilograms Step 2: Apply the BMI formula: weight / (height × height) Step 3: Display the calculated BMI value Step 4: Interpret the BMI category Basic BMI Calculator Here's a simple program to calculate BMI − height = float(input("Enter your height (m): ")) weight = float(input("Enter your weight (kg): ")) ...
Read MoreString slicing in Python to rotate a string
String rotation involves moving characters from one end of a string to the other. Python's string slicing makes this operation simple and efficient. We can rotate strings in two directions: left rotation (anticlockwise) and right rotation (clockwise). Understanding String Rotation Given a string and a rotation distance d: Left Rotation: Move first d characters to the end Right Rotation: Move last d characters to the beginning Example Input: string = "pythonprogram" d = 2 Output: Left Rotation: thonprogrampy Right Rotation: ampythonprogr Algorithm ...
Read MorePrint m multiplies of n without using any loop in Python.
Given a number n, we can print m multiples of a step value without using any loop by implementing a recursive function. This approach uses function calls to simulate iteration. Problem Statement We need to print numbers starting from n, decreasing by a step value until we reach 0 or negative, then increasing back to the original number. Example Input: n = 15, step = 5 Output: 15 10 5 0 5 10 15 Algorithm The recursive approach works as follows: Start with the given number n and a flag ...
Read MorePython program to check if there are K consecutive 1's in a binary number?
Checking for K consecutive 1's in a binary number is a common string pattern matching problem. We can solve this by creating a pattern string of K ones and checking if it exists in the binary number. Algorithm The approach involves these steps ? Take a binary string input containing only 1's and 0's Get the value K (number of consecutive 1's to find) Create a pattern string with K consecutive 1's Check if this pattern exists in the binary string Binary ...
Read MoreTokenize text using NLTK in python
Tokenization is the process of breaking down text into individual pieces called tokens. In NLTK and Python, tokenization converts a string into a list of tokens, making it easier to process text word by word instead of character by character. For example, given the input string ? Hi man, how have you been? We should get the output ? ['Hi', 'man', ', ', 'how', 'have', 'you', 'been', '?'] Basic Word Tokenization NLTK provides the word_tokenize() function to split text into words and punctuation marks ? from nltk.tokenize import ...
Read MorePython program to sort out words of the sentence in ascending order
In order to sort the words of a sentence in ascending order, we first need to split the sentence into words using space as the splitting point. For simplicity, we'll only be splitting on space and let the punctuation be there. We can use replace or regex to remove that as well. Once we split the sentence, we can sort the words lexicographically (like in a language dictionary) using either sort() or sorted() methods depending on whether we want to sort the array in place or create a new sorted array. Using sort() Method (In-Place Sorting) When ...
Read More