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.
Output
Print the addition of polynomials A and B.
The format for printing polynomials is: Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0, where Pi's are powers in decreasing order, Ci is co-efficient and C0 is constant, there will be space before and after the plus or minus sign.
If co-efficient is zero then don't print the term.
If the term with highest degree is negative, the term should be represented as -Cix^Pi.
For the term where power is 1 represent it as C1x instead of C1x^1.
****If the degree of polynomial is zero and the constant term is also zero, then just print 0 to represent the polynomial.***veryimp
For term Cix^Pi, if the coefficient of the term Ci is 1, simply print x^Pi instead of 1x^Pi.
Write your own function that illustrates a feature that you learned in this unit . The function must take time at least one argument .
. The code for the function
. The inputs and outputs to three calls of your function
.A description of what features your function illustrates
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.
In the example, the given starting number is
10, and the number of rows in the pyramid is 5.So, the output should be
10
11 12
13 14 15
16 17 18 19
20 21 22 23 24
Write a function called print_voluma (r) that takes an argument for radius of the sphere, and prints the volume of the sphere .
Call your print_volume function three times with different values for radius .
Include all the following in your learning Journal :
· The code for your print_volume function.
·The inputs and outputs of three calls of your print_volume
Implement your own version of the linked list using Python with mentioned functionalities: insert, insert at position, delete, delete at position, center, reverse, size, iterator, traverse/print.
Use of similar data structures already present in the language/framework is not allowed.
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.
L=int(input())
count=0
for a in range(1,L-1):
for b in range(a+1,L):
for c in range(b+1,L+1):
x=a*a
y=b*b
z=c*c
if (x+y==z):
count+=1
print(count)
What is the trick behind this problem
Maximum
You are given N number of inputs. Print the maximum of them after each input.
Input
The first line of input is an integer N. The next N lines each contain an integer as input.
Explanation
In the example, you are given
6 inputs 1, 0, 3, 2, 9, 8.
1 is maximum in the input 1.
1 is maximum in the input 1, 0.
3 is maximum in the input 1, 0, 3.
3 is maximum in the input 1, 0, 3, 2.
9 is maximum in the input 1, 0, 3, 2, 9.
9 is maximum in the input 1, 0, 3, 2, 9, 8.
So, the output should be
1
3
3
9
9
Sample Input 1
6
1
3
2
9
8
Sample Output 1
1
1
3
3
9
9
Sample Input 2
5
1
2
3
4
5
Sample Output 2
1
2
3
4
5
Hollow Rectangle - 2
Write a program to print a rectangle pattern of M rows and N columns using the characters as shown below.
The first line of input is an integer M. The second line of input is an integer N.
In the given example, 3 rows and 10 columns.
Therefore, the output should be
+----------+
| |
| |
| |
+----------+
Sample Input 1
3
10
Sample Output 1
+----------+
| |
| |
| |
+----------+
Sample Input 2
5
10
Sample Output 2
+----------+
| |
| |
| |
| |
| |
+----------+