Answer:
1.filename = input("Enter the input file name: ")
with open(filename, 'r') as file:
for line in file:
print(int(line.strip()))
2.filename = input("Enter the filename: ")
try:
with open(filename) as f:
count = 0
for line in f:
if int(line) < 0:
count += 1
print("Number of negative values in the file:", count)
except FileNotFoundError:
print("Error: File not found.")
Step-by-step explanation:
This are my versions of the code in Python hope it helps