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 putGiven 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 + 3I 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
The first line has an integer
Print all Armstrong numbers separated by a space.
If there are no Armstrong numbers in the given range, print
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
-1Given 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 Output7x^4 + 6x^3 + 1x^2 + 3 + 2Expected
7x^4 + 6x^3 + x^2 + 3x + 2Half 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