Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON 3.7 Program Statement: Complete Chapter 8 Programming Exercise 5, with the following modifications: Create a data file, valid_numbers.txt, containing the valid charge account numbers

PYTHON 3.7

Program Statement:

Complete Chapter 8 Programming Exercise 5, with the following modifications:

Create a data file, valid_numbers.txt, containing the valid charge account numbers as listed in the book.

Create a data file, possible_valid numbers, containing a list of possible valid numbers (such as those entered by the user). You will create this file. Include at least 10 numbers, with approximately half valid and half invalid.

Compare each charge account number from the file, possible valid numbers, to see if it is listed as a valid number in the file valid_numbers.txt.

Create an output file, results.txt which lists the possible valid numbers and the result of validity checking. Create a list of numbers, followed by "VALID", or "INVALID". Space and align neatly.

Place your name and student ID at the top of the output file.

The output should look similar to:

Checked Charge Card Number VALID/INVALID 1. 5658845 INVALID 2. 7771534 INVALID 3. 4581002 VALID

CODE

#imports go here

#Functions go here

#the main function def main(): endProgram = "no" print("") #declare variables validNumbers = open("valid_numbers.txt", 'r') possibleNumbers = open("posible_valid_numbers.txt", 'r') results = open("results", 'w') while endProgram == "no": print("") #function calls results(validNumbers, possibleNumbers) endProgram = input("Do you want to end program? (Enter no or yes): ") #vallidation while endProgram !="yes" and endProgram !="no": print("Please enter a yes or no") endProgram = input("Do you want to end the program?: ") return endProgram

#The verification function def results(validNumbers, possibleNumbers): if possibleNumbers in validNumbers: print("VALID") else: print("INVALID")

#the displayInfo function

#calls main main()

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions