menu-button

Testing & Identifying Errors

Task #1: Checking if number within a range.

Write some code that inputs a number (already done for you), and checks whether it's between 1 and 10. If it is, then thank the user via a suitable message, otherwise alert them that their number has been rejected.

Reset to Original Code     Fullscreen

Task #2: Checking if string is within an allowed length range

Write some code that inputs a string (already done for you), and checks whether it's between 5 and 15 characters. If it is, then thank the user via a suitable message, otherwise alert them that their input has been rejected.

Reset to Original Code     Fullscreen

Task #3: Checking whether input word is an animal.

Write some code that inputs a string (already done for you), and checks whether it is the name of a farmyard animal, notably: a cow, horse, pig or goose. You should raise an error if it isn't, and you check shouldn't be case sensitive, e.g. "cow" or "Cow" or "COW" would all be accepted.

Reset to Original Code     Fullscreen

Task #4: Checking whether the input is alphanumeric.

An alphanumeric character is either a letter (whether uppercase or lowercase) or a digit (0-9). Write a function that checks whether the input consists only of alphanumeric characters. Your function should return either true or false.

Reset to Original Code     Fullscreen

Task #5: Checking a sort code.

Bank sort codes help identify the bank and branch of the bank account, e.g. "Halifax bank in Kingston-upon-Thames". These are of the form XX-XX-XX where each X is a digit, for example 49-30-03. All bank accounts for IngallBank start with 40. Write a function that determines whether the input is a valid IngallBank sort code.

Reset to Original Code     Fullscreen