Server Side Programming Articles

Page 456 of 2109

How to access Python objects within objects in Python?

Rajendra Dharmkar
Rajendra Dharmkar
Updated on 25-Mar-2026 250 Views

In Python, it's common to have objects within objects, creating nested data structures. To access objects within objects, you can use the dot notation, which allows you to chain attribute access. Basic Object Composition Let's start with a simple example where a Person class contains an Address object ? class Person: def __init__(self, name, age): self.name = name self.age = age self.address = Address("123 Main St", "Anytown", "USA") ...

Read More

Check if frequency of characters are in Recaman Series in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 227 Views

Suppose we have a lowercase string s. We have to check whether the occurrences of alphabets in s, after rearranging in any possible manner, generates the Recaman's Sequence (ignoring the first term). The Recaman's sequence is defined as follows: a₀ = 0 aₙ = aₙ₋₁ - n (if aₙ₋₁ - n > 0 and not already present in sequence) aₙ = aₙ₋₁ + n (otherwise) Some of the items of Recaman's Sequence are [0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9, 24, ...]. The first term (0) is ...

Read More

Check if frequency of character in one string is a factor or multiple of frequency of same character in other string in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 353 Views

When working with two strings, we sometimes need to check whether the frequency of each character in one string is a factor or multiple of the frequency of the same character in another string. This means for each common character, one frequency should be divisible by the other. So, if the input is like s = "xxyzzw" and t = "yyyxxxxzz", then the output will be True because: Frequency of 'x' in s is 2, and in t is 4 (4 is multiple of 2) Frequency of 'y' in s is 1, and in t is 3 ...

Read More

Check if frequency of all characters can become same by one removal in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 668 Views

Sometimes we need to check if removing exactly one character from a string can make all remaining characters have equal frequencies. This problem tests our understanding of frequency counting and pattern matching. So, if the input is like s = "abbc", then the output will be True as we can delete one 'b' to get string "abc" where frequency of each character is 1. Approach To solve this, we will follow these steps ? Count frequency of all characters in the string Check if frequencies are already equal (removing any character would work) Try removing ...

Read More

How can Bokeh be used to generate scatter plot using Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 332 Views

Bokeh is a Python package that helps in data visualization. It is an open source project that renders plots using HTML and JavaScript, making it useful for web-based dashboards. Bokeh converts the data source into a JSON file which is used as input to BokehJS, a JavaScript library written in TypeScript that renders visualizations on modern browsers. Unlike Matplotlib and Seaborn which produce static plots, Bokeh produces interactive plots that change when users interact with them. Plots can be embedded in Flask or Django web applications and rendered in Jupyter notebooks. Installation Install Bokeh using pip or ...

Read More

Check If every group of a is followed by a group of b of same length in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 183 Views

Suppose we have a lowercase string s with only two characters a and b. We have to check whether every group of consecutive a's is followed by group of consecutive b's of equal length. So, if the input is like s = "abaaabbbaabbaabbab", then the output will be True, as all groups are (ab), (aaabbb), (aabb), (aabb), (ab). Algorithm To solve this, we will follow these steps − Initialize a_count to 0 and get the length of string s Set index i to 0 While i ...

Read More

Check if elements of Linked List are present in pair in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 380 Views

A linked list has elements in pairs when every element appears an even number of times. This problem can be efficiently solved using the XOR operation, which has a useful property: XORing identical numbers results in 0. Algorithm Explanation The XOR approach works because: XORing any number with itself gives 0 XOR is commutative, so order doesn't matter If all elements appear in pairs (even times), the final XOR result will be 0 If any element appears an odd number of times, the result will be non-zero Implementation Steps To solve this problem, we ...

Read More

How can Tensorflow be used to train the model with the stackoverflow question dataset using Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 490 Views

TensorFlow is a machine learning framework provided by Google. It is an open-source framework used with Python to implement algorithms, deep learning applications, and much more. It is used in research and production environments. TensorFlow has optimization techniques that help perform complicated mathematical operations quickly using NumPy and multi-dimensional arrays called tensors. The framework supports deep neural networks, is highly scalable, and comes with popular datasets. It uses GPU computation and automates resource management. The tensorflow package can be installed using the following command − pip install tensorflow Understanding Tensors A tensor is ...

Read More

Check if elements of array can be made equal by multiplying given prime numbers in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 238 Views

Given two arrays nums and primes, we need to check whether all elements in nums can be made equal by multiplying each element with one or more prime numbers from the primes array. For example, if nums = [25, 100] and primes = [2, 5], we can multiply 25 by 2 twice (25 × 2 × 2 = 100) to make both elements equal to 100. Approach The solution involves finding the LCM (Least Common Multiple) of all numbers in nums and checking if each element can be transformed to this LCM using only the given prime ...

Read More

How can Bokeh be used to generate sinusoidal waves in Python?

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 495 Views

Bokeh is a Python package that helps in data visualization. It is an open source project that renders plots using HTML and JavaScript, making it useful for web−based dashboards and interactive visualizations. Visualizing data is an important step since it helps understand patterns in the data without performing complicated computations. Bokeh produces interactive plots that change when users interact with them, unlike static plots from Matplotlib and Seaborn. Installation Install Bokeh using pip or conda ? pip3 install bokeh Or using Anaconda ? conda install bokeh Generating Sinusoidal Waves ...

Read More
Showing 4551–4560 of 21,090 articles
« Prev 1 454 455 456 457 458 2109 Next »
Advertisements