Question

Chapter 7 exercise 4, python code for Speeding violation Cal

Exercise 4 – Chapter 7 Speeding violation Calculator
Python code for the following
Design a program that calculates and displays the number of miles per hour over the speed limit that a speeding driver was doing. The program should ask for the speedlimit and the driver’s speed. Validate the input as follows:
• The speed limit should be at least 20, but not greater than 70.
• The driver’s speed should be at least the value entered for the speed limit (otherwise the driver was not speeding).
Once correct data has been entered, the program should calculate and display the number of miles per hour over the speed limit that the driver was doing.
0 0
Add a comment Improve this question Transcribed image text
Answer #1
def checklimit():
actual = input("Enter the offender's speed in mph: ")
limit = input("Enter the speed limit in mph: ")
if (limit > 20and (limit < 70):
if actual > limit:
print "Driver was going", actual-limit, "mph over the limit."
else:
print "Driver was going at a legal speed."
else:
print 'Invalid speed limit.'


answered by: codegates
Add a comment
Know the answer?
Add Answer to:
Chapter 7 exercise 4, python code for Speeding violation Cal
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Speeding Violation Calculator: Design a program that calculates and displays the number of miles per hour...

    Speeding Violation Calculator: Design a program that calculates and displays the number of miles per hour over the speed limit that a speeding driver was doing. The program should ask for the speed limit and the driver’s speed. Validate the input as follows: The speed limit should be at least 20 but not greater than 70. The driver’s speed should be at least the value entered for the speed limit (otherwise the driver was not speeding).Once correct data has been...

  • Python "Speeding Violation Calculator" Program

    Please create this program in Python and run it making sure it works... Thank you SO much in advance. :)Design a program that calculates and displays the number of miles per hour over the speed limit that a speeding driver was doing. The program should ask for the speedlimit and the driver's speed. Validate the input as follows:* The speed limit should be at least 20, but not greater than 70*The driver's speed should be at least the value entered...

  • How to write a program in python for "speed violation calculator" with a while loop and...

    How to write a program in python for "speed violation calculator" with a while loop and if statements. calculate the number of miles over the speed limit and display it. ask for the speed limit and the drivers speed the speed limit should be at least 20 but not greater than 70 if the driver's speed is less then the speed limit the driver was not speeding program should calculator and display the number of mph over the speed limit...

  • Lab 8 python code for Cell Phone Bill

    Lab 8: Cell Phone Bill CalculatorWrite the Python code for the following programming problem definition.Use modular design according to the modules specified below.Design and write a program that calculates and displays the number of minutes over the monthly contract minutes that a cell phone user incurred. The program should askthe user how many minutes were used during the month and how many minutes they were allowed. Validate the input as follows:• The minimum minutes allowed should be at least 100,...

  • I need trying to figure out how I can make create a code in Python with this exercise for I am having trouble doing so. Miles Per Gallon Calculator Write a GUI program that calculates a car's gas...

    I need trying to figure out how I can make create a code in Python with this exercise for I am having trouble doing so. Miles Per Gallon Calculator Write a GUI program that calculates a car's gas mileage. The program's window should have Entry widgets that let the user enter the number of gallons of gas the car holds, and the number of miles it can be driven on a full tank. When a Calculate MPG button is clicked,...

  • Speeding Fine Calculator You have been hired by the police department of the city you live...

    Speeding Fine Calculator You have been hired by the police department of the city you live in to create a program to calculate the fine that a motorist could pay. If the motorist was travelling at or below the speed limit, there is no fine. If the motorist is travelling over the speed limit, the amount of the fine is determined based on the table below. The speed limit that will be entered is a multiple of 5 from 5...

  • PYTHON CODE PLEASEEEEE. Driver’s License Exam 20PTS PYTHON AND FLOWCHART The local driver’s license office has...

    PYTHON CODE PLEASEEEEE. Driver’s License Exam 20PTS PYTHON AND FLOWCHART The local driver’s license office has asked you to design a program that grades the written portion of the driver’s license exam. The exam has 20 multiple choice questions. Here are the correct answers: 1.B 6.A 11.B 16.C 2.D 7.B 12.C 17.C 3.A 8.A 13.D 18.B 4.A 9.C 14.A 19.D 5.C 10.D 15.D 20.A Your program should store these correct answers in an array. (Store each question’s correct answer in...

  • Write them in python IDLE ***** 5. Average Rainfall Write a program that uses nested loops...

    Write them in python IDLE ***** 5. Average Rainfall Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations,...

  • Please have it written in Python. The distance a vehicle travels can be calculated as follows:...

    Please have it written in Python. The distance a vehicle travels can be calculated as follows: distance 5 speed 3 time For example, if a train travels 40 miles per hour for three hours, the distance traveled is 120 miles. Write a program that asks the user for the speed of a vehicle (in miles per hour) and the number of hours it has traveled. It should then use a loop to display the distance the vehicle has traveled for...

  • Python language please (also upload the result pic too) Write a program that computes and displays...

    Python language please (also upload the result pic too) Write a program that computes and displays the charges for a patient’s hospital stay. First, the program should ask if the patient was admitted as an in-patient or an out-patient. If the patient was an in-patient the following data should be entered: • The number of days spent in the hospital • The daily rate • Charges for hospital services (lab tests, etc.) • Hospital medication charges. If the patient was...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT