Welcome to Westonci.ca, where finding answers to your questions is made simple by our community of experts. Discover precise answers to your questions from a wide range of experts on our user-friendly Q&A platform. Get immediate and reliable solutions to your questions from a community of experienced professionals on our platform.

PYTHON --- Toll roads have different fees based on the time of day and on weekends. Write a function calc_toll() that has three parameters: the current hour of time (int), whether the time is morning (boolean), and whether the day is a weekend (boolean). The function returns the correct toll fee (float), based on the chart below.Weekday TollsBefore 7:00 am ($1.15)7:00 am to 9:59 am ($2.95)10:00 am to 2:59 pm ($1.90)3:00 pm to 7:59 pm ($3.95)Starting 8:00 pm ($1.40)Weekend TollsBefore 7:00 am ($1.05)7:00 am to 7:59 pm ($2.15)Starting 8:00 pm ($1.10)Ex: The function calls below, with the given arguments, will return the following toll fees:calc_toll(8, True, False) returns 2.95calc_toll(1, False, False) returns 1.90calc_toll(3, False, True) returns 2.15calc_toll(5, True, True) returns 1.05

Sagot :

The toll program illustrates the use of conditional statements;

As a general rule, conditional statements are used to make decisions

The toll program

The toll program written in Python where conditional statements are used to make several decisions is as follows:

def calc_toll(hour, morning, weekend):

   toll_fee = 0

   if weekend == False:

       if morning == True:

           if hour < 7:

               toll_fee+=1.15

           elif hour < 10:

               toll_fee+=2.95

           elif hour <= 12:

               toll_fee+=1.90

       else:

           if hour < 3:

               toll_fee+=1.90

           elif hour < 8:

               toll_fee+=3.95

           elif hour >= 8:

               toll_fee+=1.40

   else:

       if morning == True:

           if hour < 7:

               toll_fee+=1.05

           elif hour <= 12:

               toll_fee+=2.15

       else:

           if hour < 8:

               toll_fee+=2.15

           elif hour >= 8:

               toll_fee+=1.10

   return toll_fee

   

Read more about conditional statements at:

https://brainly.com/question/24833629

#SPJ1

We appreciate your visit. Hopefully, the answers you found were beneficial. Don't hesitate to come back for more information. We appreciate your visit. Our platform is always here to offer accurate and reliable answers. Return anytime. Find reliable answers at Westonci.ca. Visit us again for the latest updates and expert advice.