Testing a solution - CCEACorrective action

Once the development stage is complete you must complete integration, system and acceptance testing on your code and evaluate your solution.

Part ofDigital Technology (CCEA)Digital development practice (programming)

Corrective action

You should make an attempt to correct errors or offer alternatives.

Example: Corrective action 1

Test 3.1 failed

def validateName(): '''A function to validate and return name''' valid = False #flag to start loop while not valid: name = input('Please enter your name: ') if name !='' and len(name)<=20: and not any(char.isdigit() for char in name): #presence, length & type check print('Welcome ()'.format(name)) valid = True #break the loop return name

The original code could not detect when a user entered digits instead of letters for their name. This resulted in a error (program was expecting a string, but received an integer).

This was corrected by extending the validation rule in line 7.

The isdigit() method (a method that returns true if any character is a digit) was used to go through the name variable and check that no digits are in the name variable.

Result:

Please enter your name: Suzy7
Please enter your name: Suzy
Welcome Suzy
Please select the level of difficulty from the menu below:
1. Easy
2. Medium
3. Hard

The code now checks if any character in the name is a digit. If a digit is entered, the name will not be accepted and the user is asked to enter their name again.

You are expected to test all functions within your code and record the results.