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

X = int(input())
N = int(input())
M = 1 + 2*(N-1)
list1 = []
i = 1
j = 0
k = 0
while i <= M:
 list1.append(X**i)
 i = i + 2


for s in list1:
 if (list1.index(s))%2 == 0:
  j = j + s
 else:
  k = k - s
print(j+k)


In this python program it has three test cases, in this three test cases two test cases are getting expected output and third test case are not getting expected output. Please give me expexted output for three test cases. Thank you !

Question url :-

https://drive.google.com/file/d/15oYX0I0vkskebiNz7Wg80SdkZ-MzHTrg/view?usp=sharing

Test case 1

Input

2

5

Output

410

Test case 2

Input

3

2

Output

-24

Test case 3

Input

1

5

Output

1


write a program to print the index of the last occurence of the given number N in the list



given an array of n integers find and print all the unique triplets


Consider the following function fpp.

def foo(m):
    if m == 0:
      return(0)
    else:
      return(m+foo(m-1))

Which of the following is correct?

 The function always terminates with f(n) = factorial of n

 The function always terminates with f(n) = n(n+1)/2

 The function terminates for non­negative n with f(n) = factorial of n

 The function terminates for non­negative n with f(n) = n(n+1)/2



Add two polynomials

Given two polynomials A and B, write a program that adds the given two polynomials A and B.Input


The first line contains a single integer M.

Next M lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes co-efficient of Pi for polynomial A.

After that next line contains a single integer N.

Next N lines contain two integers Pj, Cj separated with space, where Pj denotes power and Cj denotes co-efficient of Pj for polynomial B.


Input 1

4

0 5

1 0

2 10

3 6

3

0 1

1 2

2 4

output 1

6x^3 + 14x^2 + 2x + 6


input 2

4

0 5

1 0

2 10

3 6

4

0 -5

1 0

2 -10

3 -6

output2



Given an integer number N as input. Write a program to print the double triangular pattern of N lines using an asterisk(*) character as shown below.There is space after each asterisk character.


Explanation: N = 4 there should be 2 triangle pattern with 4 lines each.


Numbers in String - 2

Given a string, write a program to return the sum and average of the numbers that appear in the string, ignoring all other characters.Input


The input will be a single line containing a string.Output


The output should contain the sum and average of the numbers that appear in the string.

Note: Round the average value to two decimal places.Explanation


For example, if the given string is "I am 25 years and 10 months old", the numbers are 25, 10. Your code should print the sum of the numbers(35) and the average of the numbers(17.5) in the new line.

Sample Input 1

I am 25 years and 10 months old

Sample Output 1

35

17.5

Sample Input 2

Tech Foundation 35567

Sample Output 2

35567

35567.0




Zig-zag order in matrix

Input:---
4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16

Output :--
1 2 3 4 5 6 7 8 9 10 11 12 16 15 14 13

Input 2:---

3 4
1 2 3 4
10 11 12 5
9 8 7 6

Output 2:--

1 2 3 4 5 12 11 10 9 8 7 6

If M = 4 and for polynomial A

For power 0, co-efficient is 5

For power 1, co-efficient is 0

For power 2, co-efficient is 10

For power 3, co-efficient is 6.


If N = 3 and for polynomial B

For power 0, co-efficient is 1

For power 1, co-efficient is 2

For power 2, co-efficient is 4.

Then polynomial A represents "6x^3 + 10x^2 + 5", the polynomial B represents "4x^2 + 2x + 1" and the addition of A and B is "6x^3 + 14x^2 + 2x + 6"


program to count how many hours we have to get coming newyear


LATEST TUTORIALS
APPROVED BY CLIENTS