Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Sample Input and Output: Test Case 1 : Please input truck 1 ' s mass: 4 4 2 5 Please input truck 2 ' s

Sample Input and Output:
Test Case 1:
Please input truck 1's mass:
4425
Please input truck 2's mass:
3906
Please input truck 2's velocity:
21.2
Please input the collision's velocity:
18.4
Please input the speed limit in km/h:
50
Doe, Jane, 12345
Please input the Last name, first name and driver license number for the driver of truck 1:
Jane Doe, Driver license number: 12345, was over the speed limit by 54.94 km/h. They have been fined $549.40
Test Case 2:
Please input truck 1's mass:
4425
Please input truck 2's mass:
3906
Please input truck 2's velocity:
21.2
Please input the collision's velocity:
18.4
Please input the speed limit in km/h:
110
Please input the Last name, first name and driver license number for the driver of truck 1:
Smith, John, 12345678
John Smith, Driver license number: 12345678, was not speeding!Part 2:
Write a Python program that asks the user for the following information within Main:
Truck 1 mass, Truck 2 mass, Truck 2 velocity, post collision velocity, speed limit where
the crash took place (in kmh), and a SINGLE string containing information about the
driver of the truck. The format of this string will be: "Last name, First name, Driver
License Number" (you can assume the user will always input this string in the correct
format)
Your program must have two functions at the top of your Python file. The first function
will be the solution to your parametric modeling from Part 1(remember, you must make
use of parameters and returns for any function you are writing based on a PM solution)
Your second function must take in the following values as parameters: The calculated
speed of Truck 1inms, the speed limit where the crash took place, and the SINGLE
formatted string (see above). The function should first convert the speed of Truck 1 into
kmh. The function should then calculate how far over or under the speed limit Truck 1
was. Based on the result, calculate a speeding fine based on the following conditions:
The function should also perform string slicing on the SINGLE formatted string and
store the 3 parts of that string as variables. (Hint remember to omit any spaces or
commas). If the driver was over the speed limit the function should print out a formatted
string: "First name Last name, Driver's license number: XXXXX, was over the speed
limit by _kmh. They have been fined $dots." Otherwise, the function should print out
"First name Last name, Driver's license number: XXXXX, was not speeding!"
Hint:
In order to extract information from the formatted string, you need to make use of the
find method, focusing on the commas.
Your final output should be contained in one single print statement, on one line.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Baccalaureate Computer Science HL And SL Option A Databases Part I Basic Concepts

Authors: H Sarah Shakibi PhD

1st Edition

1542457084, 978-1542457088

More Books

Students also viewed these Databases questions

Question

1. Identify six different types of history.

Answered: 1 week ago

Question

2. Define the grand narrative.

Answered: 1 week ago

Question

4. Describe the role of narratives in constructing history.

Answered: 1 week ago