Question: Define a function named read_and_count_multiples(filename, number) which takes a filename and an integer as parameters. The function should read all numbers from the input text

Define a function named read_and_count_multiples(filename, number) which takes a filename and an integer as parameters. The function should read all numbers from the input text file and count the number of numbers in the file that are multiples of the number parameter. The file will be a plain text file and the numbers will be separated by whitespace. You can assume that the file only contains valid integers. Remember to close the input file.

Sample files: basic_numbers.txt and numbers.txt.

For example:

Test Result
print(read_and_count_multiples('numbers.txt', 5))
6 
print(read_and_count_multiples('basic_numbers.txt', 2))
2 
print(read_and_count_multiples('basic_numbers.txt', 6))
0 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!