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 to replicate this for the n*n matrix

expected output:

enter the matrix and no of tasks: 3 2

intial matrix ([0 0 0] [0 0 0] [0 0 0])

task1: row and column 2 2

[[0 1 0] [1 1 1] [0 1 0]]

['0,0', '0,2', '2,0','2,2'] count 4

task2: row and column 1 1

[[1 1 1] [1 1 1] [1 1 0]]

['2,2'] count:1

Ans:['4','1']


Shaded Diamond

Given an integer value

N as input, write a program to print a shaded diamond of 2*N -1 rows using an asterisk(*) character 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 = 5. Therefore, the output should be

*

* *

* * *

* * * *

* * * * *

* *

* *

* *

*


Sample Input 1

6

Sample Output 1

*

* *

* * *

* * * *

* * * * *

* * * * * *

* *

* *

* *

* *

*

Sample Input 2

5

Sample


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 = 200For 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



Give two integers M and N write a program to print the first perfect square in a given range
Give two polynomials A and B write a program that adds the given two polynomials A and B

Write a program that inputs the length of two pieces of fabric in feet and inches ( as whole numbers) and prints the total

enter the feet: 3

enter the inches: 11

enter the feet: 2

enter the inches : 5


Average of Given Numbers

You are given space-separated integers as input. Write a program to print the average of the given numbers.

Input

The first line of input contains space-separated integers.

Output

The output should be a float value rounded up to two decimal places.

Explanation

In the example, input is 

1, 0, 2, 5, 9, 8. The sum of all numbers present in the list is 25, and their average is 25/6.

So, the output should be 

4.17.

Sample Input 1
1 0 2 5 9 8
Sample Output 1
4.17
Sample Input 2
1 2 3 4 5
Sample Output 2
3.0

input should be single line

Write a program to create a menu-driven calculator that performs basic arithmetic operations (+, -, *, /, and %).Input


The input will be a single line containing two integers and operator(+, -, *, /, and %) similar to 3 + 5.Output


If the given operator is "+", print the sum of two numbers.

If the given operator is "-", print the result of the subtraction of the two numbers.

If the given operator is "*", print the multiplication of the two numbers.



For example, if the given operator is "+" and the two numbers are 3 and 5. As it is an addition operator, your code should print the sum of the given two numbers (3 + 5), which is 8.

Similarly, if the given operator is "*" and the two numbers are 2 and 5.

Similarly, if the given operator is "-" and the two numbers are 10 and 9.


Sample Input 1

3 + 5

Sample Output 1

8

Sample Input 2

2 * 5

Sample Output 2


input will be single line only



In the given example the string is

messages, N = 3. So we have to repeat the string three times. Then we get messages messages messages as output.


Write a program that asks the user for their name and their height in inches ("Enter your name: ", "Enter your height in inches: "). The program should display the person's name and whether they are short, average, or tall. Short is less than 60 inches and tall is greater than 72 inches in between is average height. Display the output in the following format as an example: (Joe, " your height is short")


LATEST TUTORIALS
APPROVED BY CLIENTS