# Debit card

Simple character validation.

## Try

Select the button below to open the Python program in a new window. Run the program and read the lines of code to see if you can understand how it works. It will be helpful to arrange your display so that you can have this browser window on one side of the screen and the code on the other.

Watch this video to learn about the new concepts shown in the program:

## Investigate

Identify the Boolean variable used to flag if a character is not a number.

`valid` is a Boolean variable used to flag if a character is not a number.

State what data type is before the dot in `character.isdigit()` in line 11.

“character” is a string data type, it just happens to only contain one character. Some languages support a character data type.

## Make

### Success Criteria

Change the program so that it:

1. Asks the user to enter their name before their card number.
2. Has an additional function called `validate_name` to check whether the name only contains alphabet characters or spaces and outputs the name in upper case.

#### Typical inputs and outputs from the program would be:

Enter the name on the card: john smith

Enter the 16 digit number: 1234 1234 1234 1234

JOHN SMITH

Card details valid.

Enter the name on the card: invalidname2342

Enter the name on the card: j@hn sm!th

Enter the name on the card: john smith

Enter the 16 digit number: 1234 1234 1234 1234

JOHN SMITH

Card details valid.

#### Knowledge Organiser

Use these resources to learn about new commands for this level and to help you meet the success criteria.

###### Notes:

len(x)

Returns the number of characters in string. Can also be used to return the number of items in an array/list.

x.isupper()

Returns True if string x is in upper case or False if not.

x.islower()

Returns True if string x is in lower case or False if not.

x.isalpha()

Returns True if string x only contains alphabet letters (a-z, A-Z).

x.isdigit()

Returns True if string x only contains numbers (0-9).

x.isalnum()

Returns True if string x only contains alphabet letters or numbers.

x.isnumeric()

Returns True if string x is a number: integer or float.

x = y.lower()

x is assigned to be the lower case of y.

x = y.upper()

x is assigned to be the upper case of y (capital letters).

## Evaluate

Run the unit tests below to check that your program has met the success criteria.

Enter the name on the card: Cra1g Sargent

Enter the name on the card: Craig Sargent

Enter the 16 digit number: 5555666677778888

CRAIG SARGENT

Card details valid.

Enter the name on the card: D@ve Hillyard

Enter the name on the card: Dave Hillyard

Enter the 16 digit number: 1111 2222 3333 4444 5555 6666

Enter the 16 digit number: 1111222233334444555f

Enter the 16 digit number: 11112222333344445555

Enter the 16 digit number: 111122223333444f

Enter the 16 digit number: 1111222233334444

DAVE HILLYARD

Card details valid.

Craig ‘n’ Dave

In partnership with