A boat takes N1 hr to row a bot X1 km downstream of a river and take N2 hr to cover a distance of X2 km upstream. Find the speed of the stream.

Input:3 15 2 5Output:17.5 km/hrInput:4 29 7 30Output:47 km/hr

**Approach:**

- Take input from users
- Calculate the rate of downstream and upstream. The rate can be calculated using the formula.

- Then, calculate the speed of the stream. It is given by the formula –

**Below is the implementation.**

`def` `rate(down, up): `
` ` ` ` `# stream rate `
` ` `rate ` `=` `0.5` `*` `(down ` `-` `up) `
` ` `print` `(rate, ` `" Km/hr"` `) `
` ` ` ` `# Driver Code ` `# Distance and time downstream ` `N1 ` `=` `3`
`X1 ` `=` `15`
` ` `# Distance and time upstream ` `N2 ` `=` `2`
`X2 ` `=` `5`
` ` `# Rate of downstream and upstream ` `Rate_downstream ` `=` `X1` `/` `N1 `
`Rate_upstream ` `=` `X2` `/` `N2 `
` ` `rate(Rate_downstream, Rate_upstream) ` |

*chevron_right*

*filter_none*

**Output:**

1.25 Km/hr

Attention geek! Strengthen your foundations with the **Python Programming Foundation** Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the **Python DS** Course.

## Recommended Posts:

- Speed of boat upstream and downstream
- Speed of boat in still water from speed of stream and times taken
- Program to find Length of Bridge using Speed and Length of Train
- Python - Find Words with both alphabets and numbers
- PyQt5 QDateTimeEdit – Selecting both Date and Time text
- How to create an instance of a Metaclass that run on both Python2 and Python3?
- QA - Placement Quizzes | Time Speed Distance | Question 1
- QA - Placement Quizzes | Time Speed Distance | Question 2
- QA - Placement Quizzes | Time Speed Distance | Question 3
- QA - Placement Quizzes | Time Speed Distance | Question 4
- QA - Placement Quizzes | Time Speed Distance | Question 5
- QA - Placement Quizzes | Time Speed Distance | Question 6
- QA - Placement Quizzes | Time Speed Distance | Question 7
- QA - Placement Quizzes | Time Speed Distance | Question 8
- QA - Placement Quizzes | Time Speed Distance | Question 9
- QA - Placement Quizzes | Time Speed Distance | Question 10
- QA - Placement Quizzes | Time Speed Distance | Question 11
- QA - Placement Quizzes | Time Speed Distance | Question 12
- QA - Placement Quizzes | Time Speed Distance | Question 13
- QA - Placement Quizzes | Time Speed Distance | Question 14

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.