Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
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.
- If it is true, calculate the fine and check whether the clocked speed is greater than or equal to "90"
- 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()”.
Expert Solution & Answer
Trending nowThis is a popular solution!
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 ):
PYTHON PROGRAMMING
The date June 10, 1960, is special because when we write it in the following format,
the month times the day equals the year:
6/10/60
Write a program that ask the user to enter a month in numeric format, a day and a
two-digit year. The program should then determine whether the month times the day
is equal to the year. If so, it should display a message saying the date is Magic.
Otherwise, it should display a message saying the date is not Magic. Output should
look as shown below. Create test data and place in a file.
Name the code file Last Name + First Initial + "-MagicDates.s", for example "SmithJ-
MagicDates.s". Name the test data file in a similar manner. Upload the program and
test data files to the Dropbox.
6/10/60 is Magic!
6/10/70 is not Magic.
2/11/22 is Magic!
Chapter 7 Solutions
Python Programming: An Introduction to Computer Science, 3rd Ed.
Ch. 7 - Prob. 1TFCh. 7 - Prob. 2TFCh. 7 - Prob. 3TFCh. 7 - Prob. 4TFCh. 7 - Prob. 5TFCh. 7 - Prob. 6TFCh. 7 - Prob. 7TFCh. 7 - Prob. 8TFCh. 7 - Prob. 9TFCh. 7 - Prob. 10TF
Ch. 7 - Prob. 1MCCh. 7 - Prob. 2MCCh. 7 - Prob. 3MCCh. 7 - Prob. 4MCCh. 7 - Prob. 5MCCh. 7 - Prob. 6MCCh. 7 - Prob. 7MCCh. 7 - Prob. 8MCCh. 7 - Prob. 9MCCh. 7 - Prob. 10MCCh. 7 - Prob. 1DCh. 7 - Prob. 2DCh. 7 - Prob. 3DCh. 7 - Prob. 1PECh. 7 - Prob. 2PECh. 7 - Prob. 3PECh. 7 - Prob. 4PECh. 7 - Prob. 5PECh. 7 - Prob. 6PECh. 7 - Prob. 7PECh. 7 - Prob. 8PECh. 7 - Prob. 9PECh. 7 - Prob. 10PECh. 7 - Prob. 11PECh. 7 - Prob. 12PECh. 7 - Prob. 13PECh. 7 - Prob. 14PECh. 7 - Prob. 15PECh. 7 - Prob. 16PECh. 7 - Prob. 17PECh. 7 - Prob. 18PE
Knowledge Booster
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
- Fox International sells pre-paid calling card with the following features: Calls to USo 1.2 cents per minute plus a 49 cent connection fee per call Calls to Europeo 2.3 cents per minute plus a 49 cent connection fee per call Calls to Australiao 6.4 cents per minutes plus a 49 cent connection fee per callWrite a program that work out the charges for the month. The program should accept the followinginformation: Account holders name Card number Starting Balance on card For US callso Total number of minutes of all callso Total number of calls made For European callso Total number of minutes of all callso Total number of calls made For Australian callso Total number of minutes of all callso Total number of calls madeYou are NOT expected to error check your inputs for this assignment. (e.g. checking for negative values,etc.). There is NO GST charged on the calls as the GST was paid when the card was purchased.Format of output:Review the test plan to see how the user would like the…arrow_forwardProgramming Language: Java Direction: Write a program to determine the number of PASSED and FAILED out of 15 inputted names with the corresponding grade. Restrict the inputted grade for each name in the range of 50 to 100, in which 75 is the passing grade. If the inputted grade is not on the range, the program will remind the user of a message for the accepted range for the grade and allows the user to re-enter a grade. NOTE: MUST ADD COMMENTSarrow_forwardThe BITI Students Club is offering a new travelling package or membership. People can choose either one of three packages : a) business, b) family or c)single package. Each packages have different prices for monthly subscription. A business package is RM40, a family package is RM20 and single package is RM30. People can choose any package and duration-in-month for subscription. The program will calculate and display the total of payment. The program can be repeated as long as the option to exit is not selected. Any invalid input will result in an error message to retry. Create a program that have at least three user defined functions. Three of the functions are having the return type void and calculating the total of each packages. The display is done in separate function.arrow_forward
- Prompt Problem: A company wants a program that will calculate the weekly paycheck for an employee based on how many hours they worked. For this company, an employee earns $20 an hour for the first 40 hours that they work. The employee earns overtime, $30 an hour, for each hour they work above 40 hours. Example: If an employee works 60 hours in a week, they would earn $20/hr for the first 40 hours. Then they would earn $30/hr for the 20 hours they worked overtime. Therefore, they earned: ($20/hr 40hrs)+($30/hr 20 hrs) $800+ $600 = $1400 total. For this assignment, you must create pseudocode and a flowchart to design a program that will calculate an employee's weekly paycheck. - Write pseudocode to design a programming solution by outlining a series of steps and using appropriate indentation and keywords. As you write your pseudocode, be sure to consider the following: What input does the computer need? What steps does the program need to follow to process the input? What output should…arrow_forwardIn 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.arrow_forward5-WRITE A PROGRAM THAT CALCULATESA STUDENT'S AVERAGE IF IT IS LESS THAN 50, SPECIFYING THE STUDENT'S NAME AND AVERAGE IN RED 6-WRITE A PROGRAM THAT CHECKS THE VALUE OF A VARIABLE, WHETHER THE NUMBER ONE IS PRINTED ON SUNDAY, AND IF THE NUMBER TWO IS PRINTED ON MONDAY, AND IF THE NUMBER THREE IS PRINTED ON TUESDAY, ETC., UNTIL WE REACH FRIDAY, IT WILL PRINT A ZERO. 7-A COMPUTER COMPANY SELLS 200 PIECES OF MOTHERBOARD PER DAY, HOW MUCH DO YOU SELL PER MONTH, KNOWING THAT FRIDAY IS THE COMPANY'S HOLIDAY, KNOWING THAT THE COMPANY CONTAINS 150 EMPLOYEES AND THE SALARY OF EACH EMPLOYEE IS 2000 DOLLARS PER MONTHarrow_forward
- Write aC++program that allows a user to enter their rating of the three movies in the DarkKnight Trilogy: Batman Begins/ The Dark Knight /The Dark Knight Rises Ratings must be between 1 and 5. If a rating entered is less than 1 or more than 5, display anappropriate message and do not use the rating. After all the ratings have been entered, display each rating entered, the highest rating, the lowest rating, and the average of the ratings.arrow_forwardC#arrow_forwardWrite 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 percent of the total calories of the food, it should also display a message indicating the food is low in fat. One gram of fat has 9 calories, soCalories from fat = fat grams * 9The percentage of calories from fat can be calculated asCalories from fat ÷ total caloriesInput Validation: The program should make sure that the number of calories is greater than 0, the number of fat grams is 0 or more, and the number of calories from fat is not greater than the total number of calories.arrow_forward
- Python Programming onlyarrow_forwardProgram by using C # C sharp My student number :1910206534arrow_forwardWrite a program that calculates and displays a person’s body mass index (BMI). The BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person’s BMI is calculated with the following formula: BMI = weight × 703/height2 where weight is measured in pounds and height is measured in inches. The program should display a message indicating whether the person has optimal weight, is underweight, or is overweight. A sedentary person’s weight is considered to be optimal if his or her BMI is between 18.5 and 25. If the BMI is less than 18.5, the person is considered to be underweight. If the BMI value is greater than 25, the person is considered to be overweight.Input Validation: Determine what inputs the program needs the user to enter and what legal values the program should accept for these inputs.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
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