Question

Arithmetic Operators in python Operators        Description                  Example        &nb

Arithmetic Operators in python

Operators        Description                  Example          Calculation                  Output

=                      assignment                  x = 10

==                    equality                       x == y                                                  Is x equal to y

-x         negation        x = -10    y = -x          y == 10

x + y      addition        10 + 11                   21

x - y      subtraction     10 - 11                   - 1

x * y      multiplication 10 * 11                   110

x / y      division       25 / 10                   2.5

x // y     division trunc 25 // 10                   2

                           25// 10.0                  2.0

x % y      modulus        25 % 10                   5 (remainder)

                           25 % 7                     4 (remainder)

X ** y     exponentiation 10 ** 2                    100 (== 102 )

Suggested template PLEASE modify as needed :

fee = 0.0        # initialize  
f1 = 5.0         # table 1 fee
f2 = 4.0         # table 2 fee
f3 = 2.0         # table 3 fee

m = int(input(" Please enter number of minutes parked..."))

if (0 < m and m <= 60 ):          #table 1 minutes

  #  hrs = int(m/60) + 1          # FYI only 

    fee = f1

    print("Parking fee for ", m, " minutes is $", fee)

# now for table 2

elif (m > 60 and m <= 300):       # table 2

    # calculations needed

    print('we are in table 2 fee is ', fee)

elif ( m > 300):                  # table 3 

    #calculations needed

    print('we are in table 3 fee == ', fee)

else:

    print("error  negative minutes", m )

OUTPUT

Please enter number of minutes parked...195

we are in table 2 fee is 0.0

Algorithm :

Input: minutes parked

Output: Parking fee

Your program should ask the user for minutes parked, use the various functions/operators as needed to determine in which table 1, 2 3 the minutes falls into, compute and output the parking fee

Let m = minutes parked

fee = parking fee

Please make sure your code uses the constants: f1 f2 f3

Once you have determined your algorithm, try it for several of the minute examples provided in the tables above for accuracy

Homework Answers

Answer #1
Thanks for the question.

Below is the code you will be needing  Let me know if you have any doubts or if you need anything to change.

Thank You !!

===========================================================================

fee = 0.0  # initialize
f1 = 5.0  # table 1 fee
f2 = 4.0  # table 2 fee
f3 = 2.0  # table 3 fee
m = int(input(" Please enter number of minutes parked..."))
if (0 <= m and m <= 60):  # table 1 minutes
    #  hrs = int(m/60) + 1          # FYI only
    fee = f1
    print("Parking fee for ", m, " minutes is $", fee)
# now for table 2
elif (m > 60 and m <= 300):  # table 2
    # calculations needed
    fee = f2
    print('we are in table 2 fee is ', fee)
elif (m > 300):  # table 3
    # calculations needed
    fee = f3
    print('we are in table 3 fee == ', fee)
else:
    print("Error: negative minutes", m,'entered')

==================================================================

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Python Blackjack Game Here are some special cases to consider. If the Dealer goes over 21,...
Python Blackjack Game Here are some special cases to consider. If the Dealer goes over 21, all players who are still standing win. But the players that are not standing have already lost. If the Dealer does not go over 21 but stands on say 19 points then all players having points greater than 19 win. All players having points less than 19 lose. All players having points equal to 19 tie. The program should stop asking to hit if...
So, i have this code in python that i'm running. The input file is named input2.txt...
So, i have this code in python that i'm running. The input file is named input2.txt and looks like 1.8 4.5 1.1 2.1 9.8 7.6 11.32 3.2 0.5 6.5 The output2.txt is what i'm trying to achieve but when the code runs is comes up blank The output doc is created and the code doesn't error out. it should look like this Sample Program Output 70 - 510, [semester] [year] NAME: [put your name here] PROGRAMMING ASSIGN MENT #2 Enter...
Use Python to Complete the following on a single text file and submit your code and...
Use Python to Complete the following on a single text file and submit your code and your output as separate documents. For each problem create the necessary list objects and write code to perform the following examples: Sum all the items in a list. Multiply all the items in a list. Get the largest number from a list. Get the smallest number from a list. Remove duplicates from a list. Check a list is empty or not. Clone or copy...
I submitted this earlier with incorrect info. Can you please walk me through this problem. I...
I submitted this earlier with incorrect info. Can you please walk me through this problem. I want to confirm that I'm on the right track. Thanks. Ad Lib Cntrol Two per Day Control Food Deprived Water Deprived Food and Water Deprived 18 20 6 15 12 20 25 9 10 11 21 27 8 9 8 16 23 6 12 13 15 25 11 14 11 90 120 40 60 55 Data represent the effects of food and/or water deprivation...
What is the change in length of a metal rod with an original length of 4...
What is the change in length of a metal rod with an original length of 4 m, a coefficient of thermal expansion of 0.00002/ ° C, and a temperature change of 30° C? 1. 2.4 mm 2. 12 mm 3. 1.2 mm 4. 24 mm Determine the number of electrons passing through a point in the wire in 8 minutes when the current is 10 A. a. 3 * 1016 electrons b. none of these c. 4,800 electrons d. 1.6...
1. Find the area under the standard normal curve (round to four decimal places) a. To...
1. Find the area under the standard normal curve (round to four decimal places) a. To the left of  z=1.65 b. To the right of z = 0.54 c. Between z = -2.05 and z = 1.05 2. Find the z-score that has an area of 0.23 to its right. 3. The average height of a certain group of children is 49 inches with a standard deviation of 3 inches. If the heights are normally distributed, find the probability that a...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as possible: What is a checked exception, and what is an unchecked exception? What is NullPointerException? Which of the following statements (if any) will throw an exception? If no exception is thrown, what is the output? 1: System.out.println( 1 / 0 ); 2: System.out.println( 1.0 / 0 ); Point out the problem in the following code. Does the code throw any exceptions? 1: long value...
Bivariate Data & Probability After completing the calculation by hand in Q1 you can use Excel...
Bivariate Data & Probability After completing the calculation by hand in Q1 you can use Excel to check your answers before submitting. Q2 assesses your general understanding of probability and linear associations using Excel to analyse a large dataset. Question 1       Covariance and Correlation The table below shows a set of sample bivariate data. Calculate the covariance and correlation coefficient by completing the below table. Show all working. X Y (X - ) (Y - ) (X - )(Y -...
Q1. Use Union statements to show the following: list the number of artists that have a...
Q1. Use Union statements to show the following: list the number of artists that have a webaddress, the number of artists that do not have a webaddress, and the total number of artists. The output should look like: +--------------------------+----------+ | Has webaddress | count(*) | +--------------------------+----------+ | Has webaddress | 5 | | Does not have webaddress | 6 | | Total | 11 | +--------------------------+----------+ Q2. A new salesperson has been hired. Their SalesID is 5, full name is...
Total utility can be objectively measured in numbers that indicate usefulness or benefit to the consumer....
Total utility can be objectively measured in numbers that indicate usefulness or benefit to the consumer. ____ 2. Consumers should purchase quantities of a good to the point where MU > P. ____ 3. Voluntary exchange requires that there must be mutual gain. ____ 4. Points along a budget line represent the maximum combinations of two commodities that a consumer can afford. ____ 5. The budget line represents a consumer's preferences for a commodity. ____ 6. A change in consumer...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT