Option B is what i would say
if you are searching something and want a specific answer you are going to need to be specific on how you search it
import random
def random_number_file_writer(nums):
f = open("random.txt", "w")
i = 0
while i < nums:
f.write(str(random.randint(1,500))+"\n")
i += 1
f.close()
def random_number_file_reader():
f = open("random.txt", "r")
total = 0
count = 0
for x in f.readlines():
total += int(x)
count += 1
print("The total of the numbers is "+str(total))
print("The number of random numbers read from the file is "+str(count))
def main():
random_number_file_writer(int(input("How many random numbers do you want to generate? ")))
random_number_file_reader()
main()
I hope this helps!
Answer:
The code requests for the scores of three students for three courses offered by each student.
It calculates and print the average score for each student
Explanation:
The code written in Python programming language uses a while to get student 1-3 and a for loop to get scores for course 1-3
See attached code and output