Skip to content

Instantly share code, notes, and snippets.

@jatinsharrma
Last active August 15, 2021 08:01
Show Gist options
  • Select an option

  • Save jatinsharrma/7b94beef91d5792758a74af8397c3e8e to your computer and use it in GitHub Desktop.

Select an option

Save jatinsharrma/7b94beef91d5792758a74af8397c3e8e to your computer and use it in GitHub Desktop.
The road transport corporation (RTC) of a city wants to know whether a particular bus-route is running on profit or loss.
# The road transport corporation (RTC) of a city wants to know whether a particular bus-route is running on profit or loss.
# Assume that the following information are given:
# Price per litre of fuel = 70
# Mileage of the bus in km/litre of fuel = 10
# Price(Rs) per ticket = 80
# The bus runs on multiple routes having different distance in kms and number of passengers.
# Write a function to calculate and return the profit earned (Rs) in each route. Return -1 in case of loss.
# Also write the pytest test cases to test the program
def calculate(distance,no_of_passengers):
cost = 0
cost = 70 * distance/10
rest = 0
rest = no_of_passengers * 80
if cost <= rest :
return abs(cost - rest)
else :
return -1
distance=20
no_of_passengers=50
print(calculate(distance,no_of_passengers))
@vigneshcj001

Copy link
Copy Markdown

3860

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment