Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Multiples of 3

You are given 

N inputs. Print the numbers that are multiples of 3.

Input

The first line of input is an integer 

N. The next N lines each contain an integer as input.

Explanation

In the given example, there are 

6 inputs. 1, 2, 3, 5, 9, 6. The numbers 3, 9, 6 are multiples of 3.

So, the output should be 

3
9
6
Sample Input 1
6
1
2
3
5
9
6
Sample Output 1
3
9
6
Sample Input 2
4
1
3
6
8
Sample Output 2
3
6

Multiple of 5

You are given 

N inputs. Print the given inputs until you encounter a multiple of 5.

Input

The first line of input is an integer 

N. The next N lines each contain an integer as input.

Explanation

In the given example, there are 

6 inputs. 1, 2, 3, 5, 9, 6

After 

3, we have encountered 5, which is a multiple of 5.

So, the output should be 

1
2
3
Sample Input 1
6
1
2
3
5
9
6
Sample Output 1
1
2
3
Sample Input 2
5
1
2
3
4
5
Sample Output 2
1
2
3
4

First Prime Number

You are given 

N inputs. Write a program to print the first prime number in the given inputs.

Input

The first line of input is an integer 

N. The next N lines each contain an integer.

Explanation

In the given example of 

5 integers

1 
10 
4
3
2

The output should be 

3.

Sample Input 1
5
1
10
4
3
2
Sample Output 1
3
Sample Input 2
4
2
3
5
7
Sample Output 2
2

Composite Numbers in the range

You are given two integers 

M, N as input. Write a program to print all the composite numbers present in the given range (including M and N).

Input

The first line of input is an integer 

M. The second line of input is an integer N.

Explanation

In the given example, the composite numbers present in the range between 

2 to 9 are 4, 6, 8, 9.

So, the output should be

4
6
8
9
Sample Input 1
2
9
Sample Output 1
4
6
8
9
Sample Input 2
1
4
Sample Output 2
4

W pattern with *

Write a program to print 

W pattern of N lines using an asterisk(*) character as shown below.

Note: There is a space after each asterisk * character.

Input

The first line is an integer 

N.

Explanation

For 

N = 5

The output should be

* * * * * * * * * 
 * * * * * * * * 
  * * *   * * * 
   * *     * * 
    *       *
Sample Input 1
5
Sample Output 1
* * * * * * * * * 
 * * * * * * * * 
  * * *   * * * 
   * *     * * 
    *       *
Sample Input 2
4
Sample Output 2
* * * * * * * 
 * * * * * * 
  * *   * * 
   *     *

Armstrong numbers between two intervals

Write a program to print all the Armstrong numbers in the given range 

A to B(including A and B). An N-digit number is an Armstrong number if the number equals the sum of the Nth power of its digits.

Input

The first line has an integer 

A. The second line has an integer B.

Output

Print all Armstrong numbers separated by a space.
If there are no Armstrong numbers in the given range, print 

-1.

Explanation

For 

A = 150 and B = 200

For example, if we take number 153, the sum of the cube of digits 

1, 5, 3 is

 13 + 53 + 33 = 153.

So, the output should be 

153.

Sample Input 1
150
200
Sample Output 1
153
Sample Input 2
1
3
Sample Output 2
1 2 3

Pyramid

Given an integer 

N, write a program to print a pyramid of N rows as shown below.

Input

The first line of input is an integer 

N.

Explanation

In the example, the number of rows in the pyramid is 

5.

So, the output should be

. . . . 0 . . . . 
. . . 0 0 0 . . . 
. . 0 0 0 0 0 . . 
. 0 0 0 0 0 0 0 . 
0 0 0 0 0 0 0 0 0
Sample Input 1
5
Sample Output 1
. . . . 0 . . . . 
. . . 0 0 0 . . . 
. . 0 0 0 0 0 . . 
. 0 0 0 0 0 0 0 . 
0 0 0 0 0 0 0 0 0
Sample Input 2
6
Sample Output 2
. . . . . 0 . . . . . 
. . . . 0 0 0 . . . . 
. . . 0 0 0 0 0 . . . 
. . 0 0 0 0 0 0 0 . . 
. 0 0 0 0 0 0 0 0 0 . 
0 0 0 0 0 0 0 0 0 0 0

Profit or Loss


This Program name is Profit or Loss Write a Python program to Profit or Loss


The below link contains Profit or Loss question, explanation and test cases


https://docs.google.com/document/d/1D4lHuphIlZv7hGzq0mY8Y0-p892RyZFW/edit?usp=sharing&ouid=107231566038157986423&rtpof=true&sd=true


We need exact output when the code was run

Half String - 2

Write a program that prints the second half of the given input string.

You can assume that the length of the input string will always be an even number.

Input

The first line of input is a string.

Output

The output should be a string.

Explanation

In the given string

messages, the length of the string is 8. The last 4 characters i.e The second half of the string is ages. So the output should be

ages.

Sample Input 1

messages

Sample Output 1

ages

Sample Input 2

time

Sample Output 2

me




First Letters

You are given three strings as input. Write a program to print the first character of each string.

Input

The first, second, and third lines of input are strings.

Explanation

Consider the given strings to be

apple, banana, and carrot. We need to consider the first character in each of these strings. We get the character a from the first string apple, we get the character b from the second string banana, and we get the character c from the third string carrot. So the final output should be abc.

Sample Input 1

apple

banana

carrot

Sample Output 1

abc

Sample Input 2

Very

Important

Person

Sample Output 2

VIP




LATEST TUTORIALS
APPROVED BY CLIENTS