Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 7, Problem 6PE
Program Plan Intro

Print a message corresponding to clocked speed and speed limit

Program plan:

  • Define the function “main()”,
    • Get the clocked speed and speed limit form the user using “input()” method.
    • Calculate the difference between speed limit and clocked speed.
    • Check whether the difference is greater than or equal to "0" using “if” statement,
      • If it is true, calculate the fine and check whether the clocked speed is greater than or equal to "90"
        • If it is true, calculate fine else print fine.
    • Otherwise, check whether the difference is less than "0" using “elif” statement,
      • If it is true, then print a message as “You have not committed a speed violation”.
    • Otherwise, print the message as “Check the speed limit or reported speed.”.
  • Call the function “main()”.

Blurred answer
Students have asked these similar questions
Scenario: You have been tasked with writing a program that reads the total price of the items brought into the hypermarket and calculates the value-added tax applied to the purchase based on the following rules. If the total price is between 0 and 100, no tax will be applied. Otherwise, if the total price is between 101 and 200, the program will apply a tax of 2% of the total price. Furthermore, if the total price is between 200 and 300, the tax is 5% of the total price. Finally, if the total price is greater than 300, the tax is 10% of the total price.     hellp ):
In C#, please?   Write a program named CheckMonth2 that prompts a user to enter a birth month and day. Display an error message that says Invalid date if the month is invalid (not 1 through 12) or the day is invalid for the month (for example, not between 1 and 31 for January or between 1 and 29 for February). If the month and day are valid, display them with a message. For example, if the month entered is 2, and the day entered is 17, the output should be 2/17 is a valid birthday.
Write a program that asks for the number of calories and fat grams in a food. The program should display the percentage of calories that come from fat. If the calories from fat are less than 30% of the total calories of the food, it should also display a message indicating that the food is low in fat. One gram of fat has 9 calories, so Calories from fat = fat grams * 9. The percentage of calories from fat can be calculated as Calories from fat ÷ total calories . Input Validation: Make sure the number of calories and fat grams are not less than 0. Also, the number of calories from fat cannot be greater than the total number of calories. If that happens, display an error message indicating that either the calories or fat grams were incorrectly entered.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY