﻿ Python: Solve the specified equation - w3resource # Python: Solve the specified equation

## Python Basic - 1: Exercise-35 with Solution

Write a Python program which solve the equation:
ax+by=c
dx+ey=f
Print the values of x, y where a, b, c, d, e and f are given.

Input:
a,b,c,d,e,f separated by a single space.
(-1,000 ≤ a,b,c,d,e,f ≤ 1,000)

Sample Solution:

Python Code:

``````print("Input the value of a, b, c, d, e, f:")
a, b, c, d, e, f = map(float, input().split())
n = a*e - b*d
print("Values of x and y:")
if n != 0:
x = (c*e - b*f) / n
y = (a*f - c*d) / n
print('{:.3f} {:.3f}'.format(x+0, y+0))
``````

Sample Output:

```Input the value of a, b, c, d, e, f:
5 8 6 7 9 4
Values of x and y:
-2.000 2.000
```

Flowchart: 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

Checks if the given number falls within the given range.

Example:

```def tips_range(n, start, end = 0):
return start <= n <= end if end >= start else end <= n <= start
print(tips_range(2, 4, 6))
print(tips_range(4, 8))
print(tips_range(1, 3, 5))
print(tips_range(1, 3))
```

Output:

```False
True
False
True
```