Found 26504 Articles for Server Side Programming

Program to find out the XOR values of specific elements from a generated list in Python

Arnab Chakraborty
Updated on 20-Oct-2021 08:09:12

181 Views

Suppose we are given a list that contains natural numbers. Now from that list, we remove all the numbers that contain two consecutive 1s in its binary representation and generate another list called Z. Now we are given another list 'input_list' that contains some integer values. We have to find out the XOR value of the specified elements from Z whose indexes are specified in input_list.So, if the input is like input_list = [3, 4, 5], then the output will be 9.In indexes 3, 4, and 5 of Z; the values are 4, 5, and 8. So, 4 XOR 5 ... Read More

Program to find out the scalar products of vectors generated from an infinite sequence in Python

Arnab Chakraborty
Updated on 20-Oct-2021 08:08:29

176 Views

Suppose we are given three integer numbers c, m, and n. We have to generate an infinite sequence, where the first value is 0, the second value is c, and from the third value onwards it is equal to ki = (ki-2 + ki-1) mod m. We have to generate all the values in the series up to item k2n+1. Now from the values of the series; we take two consecutive values in the sequence as the x and y coordinates of a two-dimensional vector and generate n number of vectors. Point to be noted, we use the values in ... Read More

Python Pandas - Check if an Interval is closed on the right side

AmitDiwan
Updated on 20-Oct-2021 08:06:24

181 Views

To check if an Interval is closed on the left side, use the interval.closed_right property. At first, import the required libraries −import pandas as pdInterval set using the "closed" parameter with value "right" i.e. [0, 5) is described by 0 < x

Program to find out the sum of the number of divisor of the divisors in Python

Arnab Chakraborty
Updated on 20-Oct-2021 08:00:18

303 Views

Suppose we are given two integer numbers m and a. Now n = p1(a + 1) *p2(a + 2) *...*pm(a + m), where pi is the i-th prime number and i > 0. We have to find the value of k, where k = summation of f(x) values of n. Here f(x) values are the number of divisor values of each divisor of n.So, if the input is like m = 2, a = 1, then the output will be 60.So, n = 2^2 x 3^3n = 4 x 27n = 108The divisors of 108 are: 1, 2, 3, 4, ... Read More

Program to find out the value of a given equation in Python

Arnab Chakraborty
Updated on 20-Oct-2021 07:58:13

1K+ Views

Suppose we are given five integer numbers a, b, c, d, n. We have to find out ((ab)(cd)) mod n. The output value is an integer number.So, if the input is like a = 2, b = 3, c = 2, d = 4, n = 10, then the output will be 6.2^3 = 8 2^4 = 16 8^16 = 281474976710656 281474976710656 mod 10 = 6To solve this, we will follow these steps −Define a function helper() . This will take np := ni := 2while i * i 1, thenp := p - floor value of (p / ... Read More

Python Pandas - Check whether the interval is closed on the left-side, right-side, both or neither

AmitDiwan
Updated on 20-Oct-2021 07:54:37

162 Views

To check whether the interval is closed on the left-side, right-side, both or neither, use the interval.closed property.At first, import the required libraries −import pandas as pdClosed interval set using the "closed" parameter with value "both". A closed interval (in mathematics denoted by square brackets) contains its endpoints, # i.e. the closed interval [0, 5] is characterized by the conditions 0

Program to find out the length of the substring where two times the number of zeroes in substring is lesser than or equal to three times the number of ones in the substring in Python

Arnab Chakraborty
Updated on 20-Oct-2021 07:54:31

210 Views

Suppose we are given a string and an integer k. The string is repeated k times and made to another string. Our task is to find the length of the substring in the new string where 2 * (number of zeroes in substring) 0:          continue       else:          a = min(k - 1, -tmp // list_a[str_len])       v = a * list_a[str_len] - list_a[i]       b = bisect_left(list_b, (-v + 1, 0)) - 1       res = max(res, temp_list[b] - i + a * str_len)    return res print(solve(2, '0101011'))Input2, '0101011'Output14

Program to find out the value of a power of 2 in Python

Arnab Chakraborty
Updated on 20-Oct-2021 07:47:48

420 Views

Suppose we are given two integer numbers p and q. We have to find out the value of 22^p mod q. The output has to be an integer.So, if the input is like p = 5, q = 6, then the output will be 4To solve this, we will follow these steps −res := 2^(2^p) mod qreturn resExampleLet us see the following implementation to get better understanding −def solve(p, q): res = pow(2, 2 ** p, q) return res print(solve(5, 6))Input5, 6Output4

Program to find out the number of special numbers in a given range in Python

Arnab Chakraborty
Updated on 20-Oct-2021 07:46:48

2K+ Views

Suppose we are given a range of integer numbers and are asked to find out the special numbers in the range. A special number is a number that is a positive integer having only 1 digit in its decimal representation. A number that has more than 1 digit in its decimal representation can also be special if the number is divisible by the count of digits in its decimal representation and the quotient value is itself a special number. We return the count of special numbers in the given range (left_limit, right_limit).So, if the input is like left_limit = 5, ... Read More

Python Pandas - Create a half-closed time interval and check for existence of endpoints

AmitDiwan
Updated on 20-Oct-2021 07:53:37

134 Views

To create a half-closed time interval, use the pandas.Interval() and set the closed parameter to right. To check for existence of endpoints, use the in property.At first, import the required libraries −import pandas as pdHalf-Closed interval set using the "closed" parameter with value "right". Half-Closed i.e. (0, 5] is described by 0 < x

Advertisements