Answered step by step
Verified Expert Solution
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
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:
permitnumber: the student'slearners permit number issued by the state.
firstname: the given name of a driving student of the school.
lastname: the surname of a driving student of the school.
dateofbirth: the date of birth of the student.
Input is terminated using a permitnumber 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 isgoodpermitnum below. The permit number must be a ninedigit number. The first digit must be
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: yearmonthday. eg Please leave this date as a string. Do not convert it to a date object. See isgooddate and requirements below. You should validate:
year
month
day daysinmonth
daysinmonth if the month is or
daysinmonth if the month is or
daysinmonth if the month is 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:
isgooddate # Is the argument a valid date, eg :
# aa isgooddatefred;
# The variable aa would get the value false.
isgoodpermitnum # Is argument a valid learner's permit number.
# Eg In the following code:
# aa isgoodpermitnumfred;
# 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:
Permit no:
Given name: Tim
Surname: Lu
Birth date:
Permit no:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started