Number Plate Generator

NumberPlate

For this Python challenge we need to investigate how UK number plates work. Check this page from aa.com to learn more about the current format of number plates in the UK.

Learning Objectives:

By completing this challenge using Python we are going to learn how to use ASCII code when manipulating strings.

You will use the chr() and ord() python instructions to convert characters into ASCII code and vice versa.
For instance:

  • print(chr(65)) would display the letter “A” on screen as 65 is the ASCII code for character “A”.
  • print(ord(“A”)) would display the 65 on screen as 65 is the ASCII code for character “A”.

To complete this challenge you may want to use our ASCII code helpsheet

Challenge #1: Random Number Plate Generator

Your first challenge consists of creating a program that generate a random plate number each time it is run.

The plate number will have to adhere to this format:
2 UPPER CASE LETTERS followed by 2 digits (0 to 9) followed by a space followed by 3 UPPER CASE LETTERS

To help you we have started the code to generate a random uppercase letter. You can now complete this code to generate the full plate number.

Challenge #2: Number Plate Validator

Your second challenge consists of writing a program that will ask the user to enter a number plate. The program will then confirm whether the number plate is valid or not.

Remember, a valid number plate has to follow this format:
2 UPPER CASE LETTERS followed by 2 digits (0 to 9) followed by a space followed by 3 UPPER CASE LETTERS

unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 2.4 / 5. Vote count: 9

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: ,