Arnab Chakraborty has Published 4452 Articles

Python program to find better divisor of a number

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:33:33

316 Views

Suppose we have a number n. We have to find divisor of n which one is better based on these conditions: We have two numbers p and q, the one whose digits sum to a larger number is called better than the other one. When the sum of digits is ... Read More

Program to find length of a list without using built-in length() function in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:31:13

632 Views

Suppose we have a list nums. We have to find the length of this list but without using any length(), size() or len() type of functions.So, if the input is like nums = [5, 7, 6, 4, 6, 9, 3, 6, 2], then the output will be 9.To solve this, ... Read More

Program to find sum of odd elements from list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:26:17

6K+ Views

Suppose we have a list of n elements called nums. We have to find sum of all odd elements from the list.So, if the input is like nums = [5, 7, 6, 4, 6, 9, 3, 6, 2], then the output will be 24 because 5+7+9+3 = 24.To solve this, ... Read More

Program to reverse a list by list slicing in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:21:58

167 Views

Suppose we have a list of n elements called nums. We have to reverse this list by list slicing operations.So, if the input is like nums = [5, 7, 6, 4, 6, 9, 3, 6, 2], then the output will be [2, 6, 3, 9, 6, 4, 6, 7, 5]To ... Read More

Program to create a list with n elements from 1 to n in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:14:45

2K+ Views

Suppose we have a number n. We have to create a list of elements of size n, the elements are from 1 to n.So, if the input is like n = 5, then the output will be [1, 2, 3, 4, 5]To solve this, we will follow these steps −use ... Read More

Python program to get average heights of distinct entries

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:09:11

542 Views

Suppose we have a set of heights there may be some duplicate entries as well. We have to find the average of distinct entries of these heights.So, if the input is like heights = [96, 25, 83, 96, 33, 83, 24, 25], then the output will be 52.2 because the ... Read More

Program to find only even indexed elements from list in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:09:01

1K+ Views

Suppose we have a list of elements called nums. We have to filter out all odd indexed elements, so only return even indexed elements from that list.So, if the input is like nums = [5, 7, 6, 4, 6, 9, 3, 6, 2], then the output will be [7, 4, ... Read More

Python program to convert complex number to polar coordinate values

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:07:03

301 Views

Suppose we have a complex number c, we have to convert it into polar coordinate (radius, angle). Complex number will be in form x + yj. The radius is the magnitude of the complex number which is square root of (x^2 + y^2). And the angle is the counter clockwise ... Read More

Python program to get all permutations of size r of a string

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 07:04:29

374 Views

Suppose we have a string s and a number r. We have to display all permutations of r number of characters in s. We have permutations() function to get all permutations. This function is present inside itertools library.So, if the input is like s = "HELLO" r = 3, then ... Read More

C++ program to demonstrate exception handling

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 06:53:43

229 Views

Suppose there is a function that calculates some serious complex mathematical operations. But during the operations, some exceptions can occur. We have to handle the different types of exceptions that can occur and perform the following.If the computer is unable to allocate the memory for computation, we have to print ... Read More

Advertisements