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

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



elif op==16 :


print ("Functions Menu")


print ("j. asinh")


print ("k. acosh")


print ("l. atanh")


fun = raw_input("Choose the function :")


a = float(input("Enter the value :"))


dict6 = {'j':math.asinh(a), 'k':math.acosh(a), 'l':math.atanh(a)}


print ("The result is : " + str(dict6.get(fun)) )



else :


print ("Wrong Choice")




Question:


1. In this program, you will create a class and OOP.



elif op==14 :


print ("Functions Menu")


print ("d. asin")


print ("e. acos")


print ("f. atan")


fun = input("Choose the function :")


a = float(nput("Enter the value :"))


dict4 = {'d':math.asin(a), 'e':math.acos(a), 'f':math.atan(a)}


print ("The result is : " + str(dict4.get(fun)))




elif op==15 :


print ("Functions Menu")


print ("g. sinh")


print ("h. cosh")


print ("i. tanh")


fun = input("Choose the function :")


a = float(input("Enter the angle in radians :"))


dict5 = {'g':math.sinh(a), 'h':math.cosh(a),'i':math.tanh(a)}


print ("The result is : " + str(dict5.get(fun)) )




Question:


1. In this program, you will create a class and OOP.



if op==1 or op==2 or op==3 or op==4 or op==5 or op==6 :


a = int(input("Enter first number"))


b = int(input("Enter second number"))


dict1 = {1:a+b, 2:a-b, 3:a*b, 4:a/b, 5:a%b, 6:a**b}


print ("The result is : " + str(dict1.get(op)))



elif op==7 or op==8 or op==9 or op==10 or op==11 or op==12 :


a = float(input("Enter the number"))


dict2 = {7:math.fabs(a), 8:math.factorial(a), 9:math.log(a), 10:math.ceil(a), 11:math.floor(a), 12:math.sqrt(a)}


print ("The result is : " + str(dict2.get(op)))



elif op==13 :


print ("Functions Menu")


print ("a. sin")


print ("b. cos")


print ("c. tan")


fun = input("Choose the function :")


a = float(input("Enter the angle in radians :"))


dict3 = {'a':math.sin(a), 'b':math.cos(a), 'c':math.tan(a)}


print ("The result is : " + str(dict3.get(fun)))




Question:


1. In this program, you will create a class and OOP.

#Scientific Calculator


import math


print ("MAIN MENU")

print ("1. Addition")

print ("2. Subtraction")

print ("3. Multiplication")

print ("4. Division")

print ("5. Modulus")

print ("6. Exponentiation")

print ("7. Absolute value")

print ("8. Factorial")

print ("9. Logarithm")

print ("10. Round Up")

print ("11. Round Down")

print ("12. Square Root")

print ("13. Trigonometric Functions")

print ("14. Inverse Trigonometric Functions")

print ("15. Hyperbolic Functions")

print ("16. Inverse Hyperbolic Functions")

print("")

print ("NOTE: If you're performing operations in the 1-6 range, don't make the second number zero." )

print()

op = int(input("Enter the operation you want to perform : "))


Question:

1. In this program you will create a class and OOP


Create a program wherein the system should be able to retrieve information like who took a particular book or what are the books checked-out by a specific user.


LATEST TUTORIALS
APPROVED BY CLIENTS