
Patrick B. answered 04/10/21
Math and computer tutor/teacher
def addLine(inbuff,lineNum):
tokens = inbuff.split(" ")
#print(tokens)
N = len(tokens)
sum=0
for token in tokens:
sum = float(sum) + float(token)
print("Line " + str(lineNum) + " has " + str(N) +
" values and total is " + str(sum))
"""
###################################################
# File is open and read as follows.....
# cannot do it here because it is an online compiler
#f = open("File_Lab1.txt", "r")
inbuff = f.read()
#if f is None:
# END OF FILE !!!
#break
"""
#
#inbuff = f.read()
#input buffer inbuff now contains "10 20 30"
lineNum=1
inbuff = "10 20 30"
addLine(inbuff,lineNum)
#if not (f is None):
lineNum = int(lineNum)+1
#
#inbuff = f.read()
#input buffer inbuff now contains "20"
inbuff = "20"
addLine(inbuff,lineNum)
#f.read()
#input buffer inbuff now contains 320 5076
inbuff="20 5076"
addLine(inbuff,int(lineNum)+1)