Question 5
Edexcel Computer Science June 2023 Paper 2GCSE15 marks
On the specification
- 6.3 Data types and structures6.4 Input and output6.6 Subprograms
Question text
5 A program is being developed to generate a user identification string. The letter part of the identification string is made up of the last name joined with the first letter of the first name. All letters must be in lowercase. The number part of the identification string is the sum of the ASCII values for each of the digits in the date of birth (ddmmyyyy). The identification string for the user Viola Bassir, born 15th June 2005, is bassirv403, all in lowercase. Open file Q05.py Amend the code to: • Ensure local and global variables with the same names are not confused – change the names of the local variables to distinguish them from the global variables with the same name • Welcome the user – add a procedure, with no parameters, to display a welcome message for the user – call the welcome procedure before taking input from the user • Ensure the last name and first name are all lowercase – convert last name and first name to lowercase after they are inputted by the user • Validate the date of birth in the main program using the built-in string manipulation subprograms – check that only the digits 0 to 9 appear in the date of birth – call the makeID() function if the date of birth is valid – tell the user if the date of birth is invalid. Invalid input should not be processed • Generate the correct number part of the identification string in the makeID() function – correct the logic error caused by using the int() function in the number part calculation rather than using a function that returns the ASCII value of the character Do not add any additional functionality. Save your amended code file as Q05FINISHED.py (Total for Question 5 = 15 marks)