Question & Answer: Using Python 3, write a file containing a series of integers named numbers.dat. De…..

Using Python 3, write a file containing a series of integers named numbers.dat. Design a program that displays all of the numbers in the file.

Expert Answer

 

# Opening File
with open(‘sag.txt’, ‘r’) as my:
# Counting Total Number of Lines
total = my.readline()
#Splitting Based on Spaces
num = total.split(‘ ‘)

# Go through the numbers
for j in range(0, len(num)):
#Converting Into Integer
t = int(num[j])
# Displaying The Value
print(t)

Question & Answer: Using Python 3, write a file containing a series of integers named numbers.dat. De..... 1

Still stressed from student homework?
Get quality assistance from academic writers!