Page 288 - Learn to Program - Basic-256
P. 288
Chapter 18: Files – Storing Information For Later. Page 272
Exercises:
e n i l e t i r w e
s y r o t c e r i d
n e k o t s q h e r
e f m e t s f l e p
p p s s i i i a s c
o e i z l m d e l e
r x e e i l e o r o
e e r t i k s y e f
t k e n z e l j a d
b r e w r i t e d n
close, delimiter, directory, eof, exists, file, open, read, readline,
reset, seek, size, token, write, writeline
words
1. Create a file in the directory where you save your programs
named “numbers.txt”. Open it with a text editor, like Notepad in
Windows or gEdit in LINUX, and type in a list of decimal numbers.
Put each one on a separate line.
Now write a program to read the numbers from the file, one line
at a time. Calculate the total of the numbers in the file and the
average.
Remember to use the float() function to convert the string you
read from the file to a numeric value before you add it to the
running total.
2. Create a file in the directory where you save your programs
named “people.txt”. Open it with a text editor, like Notepad in
© 2019 James M. Reneau (CC BY-NC-SA 3.0 US)

