Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help finishing please! Problem Statement: The purpose of this lab assignment is to gain experience in python's Exception handling. In this assignment, you will

Need help finishing please!

image text in transcribed

image text in transcribed

Problem Statement: The purpose of this lab assignment is to gain experience in python's Exception handling. In this assignment, you will write a program for password validation system. Problem Design: Password Validation 1. The program will take password from user and check if it contains the following: a. Password must contain at least one letter b. Password must contain at least one digit C. Length must be between 6 to 12 characters. d. It may or may not contain any other characters like any special symbols. There is no restriction on that. 2. Helper functions to check if a password has at least one letter and at least one digit are provided. Docstring are also given in the template file. These functions return True if condition satisfies (has at least one digit/letter) otherwise returns False. 3. Your task: Design a base class (Invalid Password) and three child exception classes (InsufficientLength, NoDigit, NoLetter) to raise the exception when the conditions are not met. 4. Design a simple user menu to ask for the password as long as the user does not enter a valid password. 5. The menu should also make a try-except block to call for appropriate Exception class as needed. If none of the exception occurs the program will print a message as shown in sample 1/0. 6. A sample problem can be found in Exception video lecture use case on designing a number guessing game. You can follow the same program structure. Sample 1/0: Enter your password: 123 Password length needs to be between 6 to 12 Enter your password: aAAAAAAA Password must contain one digit (0-9) Enter your password: 1234567890 Password must contain one letter Enter your password: 123aaaAA@ Valid password: 123aaaAA@ #define parents exception class called InvalidPassword class InvalidPassword (Exception): #Base Class pass #define subclass insufficient length class passlen(InvalidPassword): def __str__(self): return "Password length needs to be between 6 to 12" #define subclass NoLetter class Letter (InvalidPassword): def __str__(self): return "Password must contain at least one letter" #define subclass NoDigit class NoDigit(InvalidPassword): def str__(self): return "Password must contain one digit (0-9)" #helper functions def has_digit(password): Checks if a password string has at least one digit. Returns True if at least one digit is present, False otherwise return any([char.isdigit() for char in password]) def has_letter(password): Checks if a password string has at least one letter. Returns True if at least one letter is present, False otherwise return any ([(ord(c)>= 97 and ord(c) = 65 and ord(c)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions