Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Image: ubuntu2004
Subway Fare
Two initial variables must be declared: one for a single fare price () and another for the weekly fare price ().
For the purpose of this exercise, the constraints that are specified. A while loop is used to check that the user value entered is greater than 1 and less than 30. If not, the user is prompted to enter a valid amount.
Once the user enters a valid number of subway rides taken per week, the function computes the product of the individual fare cost and the number of rides taken with a local value (.
Using a boolean data type, the function compares the computed user amount with the price of a weekly fare. The Boolean value returns if the purchased amount of subway rides is less than the price of a weekly fare and otherwise.
In either case, the computation of their weekly expenditure is declared for the user to view.
If the Boolean variable returns , the program prints a message telling the user that individual fares are more suited to their requirements.
If the Boolean variable returns , the program prints the message explaining to the user that weekly fares are more monetarily beneficial for their requirements. If this is the case, the program computes the price the user pays per week on subway rides then subtracting the weekly fare amount from that value (), shows the user how much they will save by purchasing a weekly fare.
This is more sophisticated that what I intended. Well presented. In the future, put the Jupyter notebook in the folder that contains the project prompt. 10/10