﻿ NumPy: Compute the given polynomial values - w3resource

# NumPy: Compute the given polynomial values

## NumPy Mathematics: Exercise-17 with Solution

Write a NumPy program to compute the following polynomial values.

Sample Solution:

Python Code:

``````import numpy as np
print("Polynomial value when x = 2:")
print(np.polyval([1, -2, 1], 2))
print("Polynomial value when x = 3:")
print(np.polyval([1, -12, 10, 7, -10], 3))
```
```

Sample Output:

```Polynomial value when x = 2:
1
Polynomial value when x = 3:
-142
```

Pictorial Presentation:

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?

Test your Python skills with w3resource's quiz

﻿

## Python: Tips of the Day

Getting rid of unwanted characters:

You can get rid of whitespaces or any specific character using strip methods in Python. You can use either plain strip for both sides, lstrip for the left side and rstrip for the right side only.

```str="+++Welcome python+++"
str.strip()

print(str)```

Output:

`+++Welcome python+++`