Related questions
Problem Statement:
The purpose of this lab assignment is to gain experience in python’s Exception handling. In this
assignment, you will write a
Problem Design: The program will take an email address from user and check if it contains the
following:
a. Address must contain at least an ‘@’ symbol
b. Address must contain at least a ‘.edu’ suffix
c. Length must contain at least 12 characters.
d. Address must contain at least one digit
2. Helper functions to check if an address has at least one digit is provided. Docstring are
also given in the template file. This function returns True if condition satisfies otherwise
returns False.
3. Your task: Design a base class (Invalid Address) and child exception classes
(InsufficientLength, NoDigit, NoEdu, NoAtSymbol ) to raise the exception when the
conditions are not met.
4. Design a simple user menu to ask for the address as long as the user does not enter a valid
address.
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 I/O.
6. Hint: A sample problem structure can be found in Exceptionslecture: designing a number
guessing game.
Sample I/O:
Enter your email address: ih@gmu.edu
Address must have at least 12 characters
Enter your email address: janedough@gmu.edu
Address must contain at least one digits (0-9)
Enter your email address: janedough22gmu.edu
Address must contain one @
Enter your email address: janedough22@gmu.com
Address must contain .edu suffix
Enter your email address: janedough22@gmu.edu
Valid address: janedough22@gmu.edu
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 3 images
- Please written by computer source Implement try/except exception handler to catch all errors (from the following source code) separately: my_string = 'Hello World' print(my_string) num = int(my_string) print(my_string + 100) num = 1/0 print(total) print('Done') Submission Instructions: 1. Write all the code in one module (in one .py file), and save it as Firstname_Lastname_hw6.py (e.g., John Adam’s file name should be John_ Adam_hw6.py).arrow_forwardDesign and implement a program that creates an exception classcalled StringTooLongException, designed to be thrown when astring is discovered that has too many characters in it. In the maindriver of the program, read strings from the user until the userenters "DONE". If a string that has too many characters (say 20) isentered, throw the exception. Allow the thrown exception toterminate the programarrow_forwardNo restriction exists on the number of arguments permitted in a catch block.arrow_forward
- Again --4. Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burning_heart_rate() to calculate the fat burning heart rate. The adult's age must be between the ages of 18 and 75 inclusive. If the age entered is not in this range, raise a ValueError exception in get_age() with the message "Invalid age." Handle the exception in __main__ and print the ValueError message along with "Could not calculate heart rate info." Ex: If the input is: 35 the output is: Fat burning heart rate for a 35 year-old: 129.5 bpm If the input is: 17 the output is: Invalid age. Could not calculate heart rate info.?.arrow_forwardTime Converter 1. Write a program that converts dates from a numerical month-day format to alphabetic month-day format. IE 1/31 or 01/31 would have an output of January 31. 1. User enters the month and day as a single string. It is then converted. (10%) 2. Create 2 exception classes (20%) 1. MonthException thrown for invalid months 2. DayException-thrown for invalid days for the given month 3. You can assume Feb is always 28 days 2. This should run in a for loop and end when a user is done entering dates (70%)arrow_forwardProgramming Problem 1 – CycleThrowTryCatch Revisit the Cycle class in Module 3. Modify your application such that the properties, numberOfWheels and weightare entered as double values interactively (at the keyboard). Exception handling will be used to determine whether a type mismatch occurs. Edit your application such that, in addition to [A], the values for numberOfWheels and weight, entered interactively, will throw a new exception "Values cannot be less than or equal to zero" only If the values are less than or equal to zero. Add or use the appropriate try and/or catch blocks. Directions Examine your application for the class called Cycle. Add Try and Catch blocks appropriately. Add the throw statement for the new exception. Display an appropriate message if an exception occurs. Display the properties of the object.arrow_forward
- Text book imageComputer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONText book imageComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceText book imageNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Text book imageConcepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningText book imagePrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationText book imageSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY