Arnab Chakraborty has Published 4452 Articles

Program to find Fibonacci series results up to nth term in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 09:00:54

350 Views

Suppose we have a number n. We have to find the sum of first n Fibonacci terms (Fibonacci sequence up to n terms). If the answer is too large then return result modulo 10^8 + 7.So, if the input is like n = 8, then the output will be 33 ... Read More

Python program to find factorial of a large number

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 09:00:24

542 Views

Suppose we have a large number n. We have to find its factorial. In some other languages it is very hard to find factorial of a large number because it may exceed the range of integer data types. But in python it will automatically detect the length and also update ... Read More

Program to find elements from list which have occurred at least k times in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:57:30

235 Views

Suppose we have a list of elements called nums, and a value k. We have to find those elements which have occurred at least k number of times.So, if the input is like nums = [2, 5, 6, 2, 6, 1, 3, 6, 3, 8, 2, 5, 9, 3, 5, ... Read More

Python program to find product of rational numbers using reduce function

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:56:49

334 Views

Suppose we have a list of rational numbers. We have to find their product using reduce function. The reduce() function applies a function with two arguments cumulatively on a list of objects from left to right.So, if the input is like fractions = [(5, 3), (2, 8), (6, 9), (5, ... Read More

Python program to validate email address

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:53:41

13K+ Views

Suppose we have an email address as string. We have to check whether this is valid or not based on the following conditions −The format must be username@company.domain formatUsername can only contain upper and lowercase letters, numbers, dashes and underscoresCompany name can only contain upper and lowercase letters and numbersDomain ... Read More

Program to find number of ways we can get a number which is sum of nth power of unique numbers in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:51:42

201 Views

Suppose we have a number x and another number n. We have to find number of ways we can get x as sum of nth power of some unique numbers.So, if the input is like x = 100 n = 2, then the output will be 3 because possible solutions ... Read More

Python program to sort string in custom order

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:51:07

711 Views

Suppose we have one alphanumeric string s. We have to sort it based on following conditionAll sorted lowercase letters will be placed before uppercase letters.All sorted uppercase letters will be placed before digits.All sorted odd digits will be placed before sorted even digits.So, if the input is like s = ... Read More

Python program to sort table based on given attribute index

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:47:21

351 Views

Suppose we have a 2d list containing information about athletes. This information is rank, age, height. Each row contains information for different athletes. We also have another number k. We have to sort the data based on kth attribute.So, if the input is likeRankageheight125190235180333185426175535180And k = 1.then the output will ... Read More

Python program to define class for complex number objects

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:44:06

4K+ Views

Suppose we want to do complex number tasks by defining a complex number class with following operations −add() to add two complex numberssub() to subtract two complex numbersmul() to multiply two complex numbersdiv() to divide two complex numbersmod() to get modulus of complex numbersThe complex numbers will be shown in ... Read More

Program to perform prefix compression from two strings in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 12-Oct-2021 08:44:04

228 Views

Suppose we have two strings s and t (both contains lowercase English letters). We have to find a list of pairs of size 3, where each pair is in this form (l, k) here k is a string and l is its length. Now among these three pairs, first one ... Read More

Advertisements