Python Answers

Questions answered by Experts: 5 288

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

Write a python program for replace negative numbers


Given an integer N, Write a program to print a pyramid of N rows as shown below.

In the example the number of rows in tbe pyramid is 5. So, the output shoyld 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


Give the number of the month , write a program to print the name of the month


Input will be a single line Containing a integer N

Given a space-separted list of integers as input, write a program to add the elements in the given range and print their sum


You will be given M multiple range queries,where

You should print the sum of numbers that belong to the corresponding range


note: while checking if the number belongs to a range,including the string and numbers of range as well


Input

The first line of input is space-separated integers

The secondline of input is a positive integers M denoting the number of queries

The next M line contain two space-separated integer

Output:

The output should be M line printing the sum of each includes range


sample input 1:

1 2 2 3 3 3 4 5 6

2

0 2

1 4


sample output1:

5

18


sampleInput2:

6 6 14 20 8 -2 2 -3

4

1 2

2 5

3 6

0 4

sampleOutput:

2

2

12

2



Are Integers Created Equally?



by CodeChum Admin




It's time to find out if something is true or false. Let's test your capabilities by creating a program that checks if two integers are equal!






Instructions:




Input two integers in one line.



Print the two integers in one line, separate them with a space.



Print a string message on a new line, "Equal" if both integers are equal

Given an M X N integer matrix, write a program to

-Find all zeros and replace them with the sum of their neighboring elements

-After replacing the zeros, set all other elements in the corresponding row and column with zeros

(excluding the elements which we previously zeros)


Note: consider the upper, lower, right and left elements as neighboring elements


Input

The first line of input is two space-separated M and N

The next M lines of input contain N space-separated integers


Output

The output should be an M X N matrix


SampleInput1:

3 3

1 2 3

4 0 2

1 1 8


Sample Output1:

1 0 3

0 9 0

1 0 8


SampleInput2:

4 5

4 8 0 0 0

4 7 0 9 7

5 5 6 9 8

7 4 3 6 7


SampleOutput2:

0 0 8 9 7

0 0 22 0 0

5 5 0 0 0

7 4 0 0 0


You are given a list of prices, where price [ i ] is the price of a given stock on the i th day


Write a program to print the maximum profit by choosing a single day to buy a stock and choosing a different day in the future to sell that stock


If there is no profit that can be achived return 0


Input:

The input is a single line containing space - separated integers


output:

The output should be a an integer


sample Input1:

7 1 5 3 6 4


sampleoutput1:

5


sampleinput2:

1 11 13 21 19


sample output2:

20


Write a program

Input: 5,3,3; Output: 5,15,45


Given a space-separted list of integers as input, write a program to add the elements in the given range and print their sum


You will be given M multiple range queries,where

You should print the sum of numbers that belong to the corresponding range


note: while checking if the number belongs to a range,including the string and numbers of range as well


Input

The first line of input is space-separated integers

The secondline of input is a positive integers M denoting the number of queries

The next M line contain two space-separated integer

Output:

The output should be M line printing the sum of each includes range


sample input 1:

1 2 2 3 3 3 4 5 6

2


sampleInput2:

6 6 14 20 8 -2 2 -3

4

1 2

2 5

3 6

0 4

sampleOutput:

2

2

12

2


Given a word W as input, write a program to print the unique character in the word, in the order of their occurrence

Note: consider lower and upper case letters as different


Input

The input is a single line containing as word W

Output:

The out should be a single line containing space- separated character


sample input: MATHEMATICS


sample Output: M A T H E I C S


LATEST TUTORIALS
APPROVED BY CLIENTS