1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
galina1969 [7]
2 years ago
5

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
Computers and Technology
1 answer:
Oduvanchick [21]2 years ago
3 0

The toll program illustrates the use of conditional statements;

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

<h3>The toll program</h3>

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:

brainly.com/question/24833629

#SPJ1

You might be interested in
The purpose of a database is to help people stop using spreadsheets.
IrinaK [193]

Answer:

Yes, the purpose of a database in a way is to stop people from using spreadsheets but, it is also so much more.

Explanation:

<u>Databases</u> are a vastly improved form of a spreadsheet. They allow Computer Scientists to automatize a company's information. Giving them the ability to instantly add, retrieve, and modify specific information within a database of hundreds or even thousands of entries. All this with little or no human input. Thus saving a company time and money as opposed to using a regular spreadsheet which requires manual input from an employee.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

3 0
3 years ago
Write a program that plays the popular scissor-rockpaper game. (A scissor can cut a paper, a rock can knock a scissor, and a pap
kolbaska11 [484]

Answer:

import random

computer = random.randint(0, 2)

user = int(input("scissor (0), rock (1), paper (2): "))

if computer == 0:

   if user == 0:

       print("The computer is scissor. You are scissor too. It is a draw")

   elif user == 1:

       print("The computer is scissor. You are rock. You won")

   elif user == 2:

       print("The computer is scissor. You are paper. Computer won")

elif computer == 1:

   if user == 0:

       print("The computer is rock. You are scissor. Computer won")

   elif user == 1:

       print("The computer is rock. You are rock too. It is a draw")

   elif user == 2:

       print("The computer is rock. You are paper. You won")

elif computer == 2:

   if user == 0:

       print("The computer is paper. You are scissor. You won")

   elif user == 1:

       print("The computer is paper. You are rock. Computer won")

   elif user == 2:

       print("The computer is paper. You are paper too. It is a draw")

Explanation:

*The code is in Python.

Import the random to be able to generate number number

Generate a random number between 0 and 2 (inclusive) using randint() method and set it to the computer variable

Ask the user to enter a number and set it to the user variable

Check the value of computer the computer variable:

If it is 0, check the value of user variable. If user is 0, it is a draw. If user is 1, user wins. If user is 2, computer wins

If it is 1, check the value of user variable. If user is 0, computer wins. If user is 1, it is a draw. If user is 2, user wins

If it is 2, check the value of user variable. If user is 0, user wins. If user is 1, computer wins. If user is 2, it is a draw

8 0
3 years ago
How do you change your password on this? This isn’t really a “Question” but....
MissTica
You go to edit profile and press the change password button.  click on profile pic
5 0
4 years ago
Read 2 more answers
Write a program that uses a forstatement to calculate and prints the sum of oddnumbers from 1 to 15
Tju [1.3M]

Answer:

#include<iostream>

using namespace std;

//main function

int main(){

   //initialization

   int sum_1=0;

   //for loop which run from 1 to 15

   for(int a1=1;a1<=15;a1++){

       if(a1%2==1){

           sum_1 = sum_1 + a1; //take the sum

       }

   }

   //display the result

   cout<<"The sum of odd number is:"<<sum_1<<endl;

   return 0;

}

Explanation:

Include the library iostream for using the input/output instruction.

Create the main function and declare the variable.

Them, take the for loop which runs from 1 to 15 and we also take the if-else conditional statement which checks the condition and if the condition is true, the statement inside the 'if' statement executes.

The condition of odd:

when the odd numbers are divided by 2, they give the remainder 1.

so, in the programming, the operator modules (%) is the only one which gives the output remainder.

suppose, 5%2 it gives the output 1.

so, the condition of an odd number is (number%2==1) we put this condition in the if statement and when the condition is true then, we take the sum of that number and store back in the sum as well.

when all number will check then the loop will terminate and finally, we display the result on the screen.

5 0
3 years ago
Which of the following memories would NOT be an example of long-term memory? a. acknowledging that you just sat down b. remember
Sati [7]

Answer: the following memories would NOT be an example of long-term memory are the letter  a) and c)

<em> -acknowledging that you just sat down </em>

-recollecting what you had for breakfast an hour ago

Explanation:

as the Long-term memory, also called inactive memory or secondary memory, is a type of memory that stores memories for a period of time greater than five o six months

6 0
3 years ago
Other questions:
  • These systems consist of interlinked knowledge resources, databases, human experts, and artificial knowledge agents that collect
    9·1 answer
  • Write an overloaded constructor for the Table class that will take a single argument for the color of the table Write a set meth
    13·1 answer
  • In the middle of the iteration, how should a team handle requirement changes from the customer? (1 correct answer)
    7·2 answers
  • I NEED SOME MAJOR HELP W/ THIS!!! PLSSS. WHOEVER HELPS GETS 80 POINTS!!! I NEED IT DONE SOON! TYY &lt;3;)
    13·1 answer
  • 50 POINTS PLEASE HELP MEEEEEEEEE!!!!!!
    6·2 answers
  • Greyer Corp, manufactures surgical instruments. Systems Medico Inc. enters into a contractual arrangement with Greyer that allow
    7·1 answer
  • The premise of this exam is to synthesize your knowledge and understanding of recursion. Your synthesize may be in the form of a
    14·1 answer
  • Your computer has been showing signs of a malware infection, and today it started up in Safe Mode. Because your computer is not
    6·1 answer
  • Where is the fill handle located
    7·1 answer
  • Who played Anne in the green gables??
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!