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 program to count Vowels and Consonants in string.

Online Book Merchants offers premium customers 1 free book with every purchase of 5 or more books and offers 2 free books with every purchase of 8 or more books. It offers regular customers 1 free book with every purchase of 7 or more books, and offers 2 free books with every purchase of 12 or more books. Write a statement that assigns freeBooks the appropriate value based on the values of the boolean variable isPremiumCustomer and the int variable nbooksPurchased.


the out put should be 12x^4 + 9x^3 - 5x^2 - x - 1 but our code does not give this out put




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


Input

 5

0 -2

3 6 

4 7

1 -3

2 -1

 5

0 1

1 2

2 -4

3 3 

4 5


Your Output

12x^4 + 9x^3 - 5x^2 - 1x - 1

Expected

12x^4 + 9x^3 - 5x^2 - x - 1



Please Find Error


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


Input

7

0 2

1 3

2 1

5 0

3 6

4 7

6 -9

5

0 1

2 4

3 0

1 0

4 -5


Your Output : - 9x^6 + 2x^4 + 6x^3 + 5x^2 + 3x + 3
Expected: -9x^6 + 2x^4 + 6x^3 + 5x^2 + 3x + 3


I need exact output like this expected output and I want to pass each and every testcase for this program






When input is "python learning" output displayed is 16-25-20-8-15-14- 12-5-1-18-14-9-14-7 there is additional - after 14 digit. how to rectify this issue?


Speed Typing Test

In this assignment, let's build a Speed Typing Test by applying the concepts we learned till now.

Refer to the below image.

https://assets.ccbp.in/frontend/content/dynamic-webapps/speed-typing-test-output.gif



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


6 / 8 Test Cases Passed

*When you submit the code, we will run it against a set of exhaustive test cases.


Input

1

2


10

15


Your Output


Expected

-1

Given polynomial, write a program that prints polynomial in Cix^Pi + Ci-1x^Pi-1 + .... + C1x +

The first line contains a single integer N.

Next N lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes coefficient of Pi.Output


For term Cix^Pi, if the coefficient of the term Ci is 1, print x^Pi instead of 1x^Pi.Explanation

N <= 100

0 <= Pi < 1000

-1000 <= Ci <= 1000

Sample Input

4

0 5

1 0

2 10

3 6

Sample Output

6x^3 + 10x^2 + 5

Failed Testcases:

Your Output


7x^4 + 6x^3 + 1x^2 + 3 + 2

Expected


7x^4 + 6x^3 + x^2 + 3x + 2






Half Pyramid - 4

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

24 

23 22 

21 20 19 

18 17 16 15 

14 13 12 11 10


LATEST TUTORIALS
APPROVED BY CLIENTS