Assignment, Variables, Constants & Sequences
Inputs, Outputs & Type Conversion
IF Statements & Boolean Operators
Nested Selection and Iteration
WHILE, REPEAT-UNTIL Loops
Validation and verification
Validation and authentication routines
High-level & Low-level languages
Assemblers, Compilers & Interpreters
To open a file in python we use the open() function.
We put the name of the file inside of speach marks "demo.txt"
The "r" means open the file for reading only.
We then assign the file to the myFile variable, which is an object.
We then use the read() method for reading the contents of the file:
To read all of the file we can loop through each line like this:
We open the file "demo.txt" and append, "a", the text to the file using write:
We open the file "demo.txt" and overwrite the content "w" :
1. Before starting the coding task you must click on the Python for Beginners link under the notes and read through.
2. Click on the button below and complete as many exercises as you can
I can copy code to read from or write to a text file.
I can create my own text file and read and write to it.
I can use a text file in my own program to read from and write data to.