Arnab Chakraborty has Published 4173 Articles

Python program to find Cartesian product of two lists

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 12:35:53

6K+ Views

Suppose we have two list of data l1 and l2. We have to find Cartesian product of these two lists. As we know if two lists are like (a, b) and (c, d) then the Cartesian product will be {(a, c), (a, d), (b, c), (b, d)}. To do this ... Read More

Python program to print rangoli pattern using alphabets

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 12:26:42

5K+ Views

Suppose we have a number n. We have to create alphabet rangoli of n x n size. n must be within 1 and 26 and it will start from a and end at z when n is 26.So, if the input is like 5, then the output will be--------e-------- ------e-d-e------ ... Read More

C++ program to print values of different data types provided as input

Arnab Chakraborty

Arnab Chakraborty

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

2K+ Views

Suppose we are given an integer value, a long value, a character value, a float value, and a double value as inputs. We have to print the values that are given to us as input maintaining their precision.So, if the input is like integer value = 15, long value = ... Read More

C program to demonstrate usage of variable-length arrays

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 11:52:27

374 Views

Suppose we are in charge of building a library system that monitors and queries various operations at the library. We are now asked to implement three different commands that perform the following −By using command 1, we can record the insertion of a book with y pages at shelf x.By ... Read More

C program to find out the maximum value of AND, OR, and XOR operations that are less than a given value

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 11:36:58

2K+ Views

Suppose we are given two integers k and n. Our task is to perform three operations; bitwise AND, bitwise OR, and bitwise XOR between all pairs of numbers up to range n. We return the maximum value of all three operations between any two pairs of numbers that is less ... Read More

Python Program to calculate function from indicator random variable from given condition

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 11:22:04

352 Views

Suppose we have two values k and n. Consider a random permutation say p1, p2, ..., pn of first n natural numbers numbers 1, 2, ..., n and calculate the value F, such that F = (X2+...+Xn-1)k, where Xi is an indicator random variable, which is 1 when one of ... Read More

Python program to print decimal octal hex and binary of first n numbers

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 11:21:48

1K+ Views

Suppose we have a value n. We have to print Decimal, Octal, Hexadecimal and Binary equivalent of first n numbers (1 to n) in four different columns. As we know, we can express the numbers with prefix characters d, o, X and b for decimal, octal, hexadecimal and decimal respectively.So, ... Read More

Python program to print design door mat texture using characters

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 11:16:15

669 Views

Suppose we have two numbers n and m, m will be multiple of n. We have to draw a door mat pattern with a word say "WELCOME" in the middle. The mat size will be n x m. We have to make this mat using dots(.), hyphens (-), pipe symbols ... Read More

Python program to wrap a text into paragraph with width w

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 11:11:31

1K+ Views

Suppose we have a string s and width w. We have to wrap this text into a paragraph with width w. This can be done very easily with fill() function present inside textwrap library. So we have to import textwrap library first.So, if the input is like s = "The ... Read More

Python program to show diamond pattern with 2n-1 lines

Arnab Chakraborty

Arnab Chakraborty

Updated on 11-Oct-2021 11:07:52

2K+ Views

Suppose we have a number n. We have to draw a diamond pattern with asterisks with 2n-1 lines. First 1 to n lines contain 1 to n number of asterisks, and next they are decreasing from n-1 to 1.So, if the input is like n = 5, then the output ... Read More

Advertisements