Write a program that outputs the following information from the numbers.txt file using StreamReader: a. The 5000th number in the file b. The largest number in the file Only output the two requested values, do not output any other numbers.

Respuesta :

# open the file in read mode

with open("numbers.txt", "r") as f:

   # create a StreamReader object

   reader = f.readlines()

   

   # get the 5000th number in the file

   5000th_number = reader[4999]

   

   # find the largest number in the file

   largest_number = max(reader)

   

# print the results

print("The 5000th number in the file is:", 5000th_number)

print("The largest number in the file is:", largest_number)