Question
Write a Python program with the following requirements: Note: A file called data_file.txt will be used. The file will already contain data, and example of
Write a Python program with the following requirements: Note: A file called data_file.txt will be used. The file will already contain data, and example of the file contents is provided on Blackboard. You must create this file with some contents. The program shall: i. Ask the user to enter a 7-digit telephone number from the user. Check to make sure that the user has entered valid numbers only. If not, display a message. Check to make sure that the user has entered 7 digits. If not, display a message. ii. Lookup the number in the file data_file.txt. If the number already exists in the file, the program displays a message that the record already exists. If the number does not exist in the file, the number should be added to the end of the file as a new row. iii. Program should continue to run and accept numbers until the user decides to quit. You can decide how the user should quit perhaps enter Q to quit, or some other indication. Handle upper and lower case letters. Structure the code such that there is: 1.) a main part of the program, 2.) a main function, and 3.) a function that will process the number - it has one input parameter, phone_number, and it will read / write to the file Hint: You need to open the file in 'r+ ' mode (which allows both read and write). You can use the with open statement. You do not need to catch exceptions.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started