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

Digit 9

You are given

N as input. Write a program to print the pattern of 2*N - 1 rows using an asterisk(*) as shown below.Note: There is a space after each asterisk * character.Input

The first line of input is an integer

N.Explanation

In the given example,

N = 4.So, the output should be

* * * *
*     *
*     *
* * * *
      *
      *
* * * *



Sample Input 1

4

Sample Output 1

* * * *
*     *
*     *
* * * *
      *
      *
* * * 

Sample Input 2

5

Sample Output 2


* * * * * 
*       *
*       *
*       *
* * * * * 
        *
        *
        *
* * * * *




Half Pyramid - 3

Given an integer

N as a starting number and K as input, write a program to print a number pyramid of K rows as shown below.Input

The first line of input is an integer

N. The second line of input is an integer K.Explanation

In the example, the given starting number is

10, and the number of rows in the pyramid is 5.So, the output should be

input-1

10

5

output-1

10

11 12

13 14 15

16 17 18 19

20 21 22 23 24


Sample Input 2

1

3

Sample Output 2

1

2 3

4 5 6




How to make object as callable video __call__
from collections import Counter
class MyCounter(Counter):
Add here required code so that we can give data to object like co1("intel")
co1 = MyCounter()
co1("intel")

For example, an array A = [10, 20, 30] and a value x = 25.

We have values 10, 20, 30 at indices 0,1,2 respectively.

  • Here index 0 is invalid because
  • 10 + 25 = 35 is less than 20 + 30 = 50
  • Here index 1 is valid because
  • 20 + 25 = 45 is greater than 10 + 30 = 40
  • Here index 2 is valid because
  • 30 + 25 = 55 is greater than 10 + 20 = 30

So there are 2 valid indices.

Sample Input 1

[1, 2, 3, 5, 7]

13

Sample Output 1

3


A number N is given as input. Write a program to check if N is positive or negative.

N = -12.5. As the value of N is less than 0, the output should be Negative.



Sum of the series

Write a program to find the sum 

S of the series where S = x - x^3 + x^5 + ....... upto N terms.

Input

The first line of input is an integer 

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

Explanation

If we take 

X value as 2 in the series upto 5 terms.

Then the series is 2 - 23 + 25 - 27 + 29

So, the output should be 

410.

Sample Input 1
2
5
Sample Output 1
410
Sample Input 2
3
2
Sample Output 2
-24

Inverted Solid Right Triangle

Given an integer number 

N as input. Write a program to print the right-angled triangular pattern of N lines as shown below.

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

Input

The first line of input is an integer 

N.

Explanation

In the given example the solid right angled triangle of side 

4. Therefore, the output should be

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

Solid Right Angled Triangle - 2

Given an integer number 

N as input. Write a program to print the right-angled triangular pattern of N lines as shown below.

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

Input

The first line of input is an integer 

N.

Explanation

In the given example, the solid right-angled triangle of side 

5. Therefore, the output should be

        * 
      * * 
    * * * 
  * * * * 
* * * * *
Sample Input 1
4
Sample Output 1
      * 
    * * 
  * * * 
* * * *
Sample Input 2
6
Sample Output 2
          * 
        * * 
      * * * 
    * * * * 
  * * * * * 
* * * * * *

Right Angled Triangle - 3

Given an integer number 

N as input. Write a program to print the right-angled triangular pattern of N rows as shown below.

Input

The first line of input is a positive integer.

Explanation

For example, if the given number is 

5, the output should be

______
|    /
|   /
|  /
| /
|/
Sample Input 1
5
Sample Output 1
______
|    /
|   /
|  /
| /
|/
Sample Input 2
7
Sample Output 2
________
|      /
|     /
|    /
|   /
|  /
| /
|/

Hollow Right Triangle - 2

Given an integer number 

N as input. Write a program to print the hollow right-angled triangular pattern of N lines as shown below.

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

Input

The first line of input is an integer 

N.

Explanation

In the given example the hollow right angled triangle of side 

5. Therefore, the output should be

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

LATEST TUTORIALS
APPROVED BY CLIENTS