Vanity Plates



In Massachusetts, home to Harvard University, it's possible to request a vanity license plate for your car, with your choice of letters and numbers instead of random ones. Among the requirements, though, are:

In plates.py, implement a program that prompts the user for a vanity plate and then output Valid if meets all of the requirements or Invalid if it does not. Assume that any letters in the user's input will be uppercase. Structure your program per the below, wherein is_valid returns True if s meets all requirements and False if it does not. Assume that s will be a str. You're welcome to implement additional functions for is_valid to call (e.g., one function per requirement).

def main():
    plate = input("Plate: ")
    if is_valid(plate):
        print("Valid")
    else:
        print("Invalid")


def is_valid(s):
    ...


main()
Hints

Before You Begin

Use ssh program such as putty to login to practice server (158.108.112.10) with your account:

Then execute

cd cpe113

to change directories into that folder.

Then execute

mkdir plates

to make a folder called plates in your cpe113 folder. Then execute

cd plates

to change directories into that folder. You can now execute

nano plates.py

to make a file called plates.py where you'll write your program.

Demo


How to Test

Here's how to test your code manually:

Run your program with python plates.py. Type CS50 and press Enter. Your program should output:
Valid

Run your program with python plates.py. Type CS05 and press Enter. Your program should output:
Invalid

Run your program with python plates.py. Type CS50P and press Enter. Your program should output
Invalid

Run your program with python plates.py. Type PI3.14 and press Enter. Your program should output:
Invalid

Run your program with python plates.py. Type H and press Enter. Your program should output:
Invalid

Run your program with python plates.py. Type OUTATIME and press Enter. Your program should output:
Invalid

You can execute the below to check your code using check50, a program that cpe113 will use to test your code when you submit. But be sure to test it yourself as well!

check50 thanawat-ku/problems/cpe113/2022/plates

Green smilies mean your program has passed a test! Red frownies will indicate your program output something unexpected. Visit the URL that check50 outputs to see the input check50 handed to your program, what output it expected, and what output your program actually gave.

How to Submit

In your terminal, execute the below to submit your work.

submit50 thanawat-ku/problems/cpe113/2022/plates