Question: Q1- Read phone numbers input by the user, one per line, without giving a prompt. When the input line is quit, stop accepting input. As
Q1- Read phone numbers input by the user, one per line, without giving a prompt. When the input line is quit, stop accepting input. As output, print the phone numbers with area code 416, each on a separate line.
The phone numbers are all in one of these two forms:
AAA-XXX-XXXX
or
XXX-XXXX
where AAA is the area code, and XXX-XXXX is the rest. If AAA is missing, it is assumed to be 416; in your program, define 416 as a named value rather than using it as a magic number (that is, create a variable whose value is 416 and use this variable rather than repeatedly using the literal 416). When producing output, add 416 to phone numbers whose area code is missing.
Requirements:
- Use ordinary string operations (not regular expressions) to work with the phone numbers.
- You should have a function that returns true or false depending on whether the area code of a phone number matches.
Example: When the input is:
416-887-2345
905-887-2345
585-4596
quit
The output should be:
416-887-2345
416-585-4596
Q2: Write a program in python to read file1.txt and try to extract all the email addresses and phone number you will find in this file.
Requirements:
- Write a module naming py_find, which have py_find.emails, and py_find.phones to extract the information form text by using regular expression.
- Using Handle error in main program to handle file not found and other exceptions.
- Need to download the file1.txt from lab3.
- Need to show the exception when there is no exist file.
Console
Starting Lab week 4
################################
Name:
Student_ID: 00000000000 # replace 00000000000 with your student ID
Date: Feb 2, 2021
Desc: Running Question 2
################################
File name: file1.txt
Line number: 5 Type: email Contain: user@demo.com
Line number: 8 Type: email Contain: user@demo.com
Line number: 10 Type: phone Contain: 666-233-0988
Starting Lab week 4
################################
Name:
Student_ID: 00000000000 # replace 00000000000 with your student ID
Date: Feb 2, 2021
Desc: Running Question 2
################################
File name: file3.txt
Error: File3.txt doesnt exist.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
