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 Nilesh Kumar
5 articles
Random Replacement of words using Python
Random word replacement is a text manipulation technique where we randomly select a word from input text and replace it with a randomly chosen word from a predefined list. This process introduces variation and generates different text versions, useful for content generation, testing, and creative writing. Python provides excellent tools for implementing random word replacement through the random module, which helps generate random indices for selecting words from text and replacement lists. Syntax The key functions used for random word replacement are ? random.randint(start, stop) Returns a random integer from the specified range. ...
Read MorePython - Product and Inter Summation dictionary values
In Python, dictionaries store key-value pairs where we can perform mathematical operations on the values. This article demonstrates how to calculate the sum and product of dictionary values using the values() method and loops. Syntax The primary method used is ? dictionary.values() The values() method returns a view object containing all dictionary values. It takes no arguments and allows iteration through values without accessing keys. Sum of Dictionary Values To calculate the sum, we initialize a variable to 0 and add each dictionary value ? def calculate_sum(dictionary): ...
Read MoreHow to Print the Last Word in a sentence using Python?
Extracting the last word from a sentence is a common text processing task in Python. This can be accomplished using the split() method to break the sentence into words and accessing the last element. Using split() Method The split() method divides a string into a list of words, making it easy to access the last word using negative indexing. Syntax string.split(separator, maxsplit) Parameters: separator − Optional. Specifies the delimiter (default is whitespace) maxsplit − Optional. Maximum number of splits (default is -1 for all occurrences) Example def print_last_word(sentence): ...
Read MoreHow to Produce K evenly spaced float values in Python?
Introduction to Produce K evenly spaced float values in Python This article will focus on how to produce k evenly spaced float value using Python. As we know python is an open-source, flexible programming language that offers a huge number of functions for manipulating data and analysis. In this article, we will understand how to produce k evenly spaced float values in Python, where k would be the number of values that has to be printed. The method to find evenly-spaced float values is used in many real-life applications such as in scientific computing, data visualization, and in mathematical operations. ...
Read MoreHow to Print a Heart Pattern Using Python?
Introduction In this article, we are going to focus on how to print a heart pattern using Python. We will look into the syntax of the function that is going to be used in the code. We will also learn about the method definition and the arguments that the method will take and their purpose. As we all know python is an open-source versatile programming language that provides a huge number of modules and functionalities to accomplish our task. with Python's simplicity and readability, we can transform our computer screen into a canvas with just a few lines of code. ...
Read More