Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4 . Write a program for a driving school. Your program will enter the details of many students, and then print out all the details

4. Write a program for a driving school. Your program will enter the details of many students, and then print out all the details using Python.
Input
In real life, you might use a form for entering data, but for the sake of this exam question, please use the input() function.
For each student record, the user of your software needs to enter the following fields in order:
permit_number: the student's/learner's permit number issued by the state.
first_name: the given name of a driving student of the school.
last_name: the surname of a driving student of the school.
date_of_birth: the date of birth of the student.
Input is terminated using a permit_number of "END".
Validation as part of the Input
You will need to validate the following fields:
the learner's permit number needs to be valid. See is_good_permitnum() below. The permit number must be a nine-digit number. The first digit must be 0.
the given name and surname must not be empty strings.
the date of birth needs to be a valid date. We assume the user will enter the date of birth as a single string according to the format: year-month-day. e.g."1965-11-23","1988-1-3". Please leave this date as a string. Do not convert it to a date object. See is_good_date() and requirements below. You should validate:
year>1960
1<= month <=12
1<= day <= days_in_month
days_in_month =30 if the month is 4,6,9 or 11
days_in_month =31 if the month is 1,3,5,7,8,10 or 12
days_in_month =28 if the month is 2(Leap year is not considered in the question)
In case of input errors, you will issue an error message and input again.
Please complete the following functions in your program. They each take a single string argument and return a boolean value of true if the argument is valid and return false otherwise:
is_good_date() # Is the argument a valid date, e.g. :
# aa = is_good_date()("fred");
# The variable aa would get the value false.
is_good_permitnum() # Is argument a valid learner's permit number.
# E.g. In the following code:
# aa = is_good_permitnum("fred");
# The variable aa would get the value false.
Output
The output is generated using the print function and using a blank line to separate records. Student records SHOULD appear as follows:
Given name: Fred
Surname: Bloggs
Birth date: 1965-11-23
Permit no: 021983745
Given name: Tim
Surname: Lu
Birth date: 1988-1-2
Permit no: 016983773

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_2

Step: 3

blur-text-image_3

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

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

Stages of a Relationship?

Answered: 1 week ago