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

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.

Output

Explanation

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.

sample output :

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

sample Input:

4

0 5

1 0

2 10

3 6

4

0 -5

1 0

2 -10

3 -6

sample output:



input:

1 20 3

30 10 2

5 11 15


output:

[[1, 2, 3], [5, 10, 11], [15, 20, 30]]


expected output:

1 2 3 
5 10 11 
15 20 30 

Temperature Conversion


You are given the temperature T of an object in one of Celsius, Fahrenheit, and Kelvin scales.

Write a program to print T in all scales viz Celsius, Fahrenheit, and Kelvin.

Formula to convert from Fahrenheit F to Celsius C is C = (F - 32) * 5 / 9.

Formula to convert from Kelvin K to Celsius C is C = K - 273.

Here "C", "F", "K" represent that the temperature scale is in Celsius, Fahrenheit and Kelvin scales respectively.

The input contains the temperature (a number) and the unit of the temperature scale (C, F, K) without any space.

The output contains temperature in Celsius, Fahrenheit and Kelvin scales in each line in the format similar to input and the value of the temperature is rounded to 2 decimal places


Explanation


For example, if the given temperature Value is 25C then Celsius value is 25.0C, Fahrenheit value is 77.0F, and Kelvin value is 298.0K.





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 ,kindly guide me?


while run this code

input: python

and it show out is :

kbgslm



Errors/Warnings:

Traceback (most recent call last):

 File "main.py", line 8, in <module>

  inp = input()

EOFError: EOF when reading a line



expected output:

kbgslm



One Color


Given a string of length N, made up of only uppercase characters 'R' and 'G', where 'R' stands for Red and 'G' stands for Green. Find out the minimum number of characters you need to change to make the whole string of the same colour.


Input


The input will be a single line containing a string.


Output


The output should be single line containing the integer representing the minimum number of characters you need to change to make the whole string of the same colour.



Explanation


For example, if string is "GGGGGGR" . We need to change only the last character to 'G' to make the string same-coloured.


then output is 1.

For example, if the given range is 2 to 11

odds numbers in the range are 3, 5, 7, 9, 11 then count is 5.

even numbers in the range are 2, 4, 6, 8, 10 then count is 5.


For example, if the given string is "Good Morning"

Vowels in the string "Good Morning" are "o, i" and their count is 4.

Remaining characters in the string are consonants their count is 7.

The First line of output is 4\nThe second line of output is 7.


For example, if the given number is 5, then read the inputs in the next 5 lines and print the sum of non-primes in the given five numbers. If the given input integers in the next five lines are 8, 11, 96, 49, and 25 the output should be 8 + 96 + 49 + 25 is 178.


import numpy as np

import scipy.linalg as la

import matplotlib.pyplot as plt

5. Use the np.linspace function to create a row vector called meshPoints

containing exactly 500 values with values evenly spaced between -1 and 1.

 

6. What expression will yield the value of the 53th element of meshPoints?

What is this value?

 

7. Produce a plot of a sinusoid on the interval [−1, 1] using the command

 

plt.plot(meshPoints,np.sin(2*pi*meshPoints))


LATEST TUTORIALS
APPROVED BY CLIENTS