1.

A taxi ride costs P40.00 as plug down rate and each additional meter(or a fraction of there of)adds Php4.00 to the fare.Use a function to represent the taxi fare in terms of distance in meters

Answer»

ong>Answer:

Write a function called taxi_fare that computes the fare of a taxi ride. It takes two inputs: the distance in kilometers (d) and the AMOUNT of WAIT time in minutes (t). The fare is CALCULATED like this:

the first km is $5

every additional km is $2

and every minute of waiting is $0.25.

Once a km is STARTED, it counts as a WHOLE (Hint: consider the ceil built-in function). The same rule applies to wait times. You can assume that d >0 and t >= 0 but they are not necessarily integers. The function returns the fare in dollars. For example, a 3.5-km ride with 2.25 minutes of wait costs $11.75. Note that loops and if-statements are neither necessary nor allowed.



Discussion

No Comment Found

Related InterviewSolutions