This Python program calculates the fare for a given distance based on the following criteria:
- For the first 10 kilometers, the fare is Rs. 11 per kilometer.
- For the next 9 kilometers (from 11 to 19 km), the fare is Rs. 10 per kilometer.
- For distances beyond 19 kilometers, the fare is Rs. 9 per kilometer.
-
Run the
fare_calculator.py
script using Python. -
Enter the distance you've covered in kilometers when prompted.
-
The program will calculate and display the total fare based on the criteria.
-
If the entered distance is invalid, it will display "Invalid distance."
Enter the distance (in kilometers): 15 The total fare for 15 km is Rs. 140
You can test the program online using Trinket by following this link.https://trinket.io/
If you encounter any issues or have questions, please don't hesitate to reach out for support.