Lesson Objectives
Use Python to write to a text file
Add data to an existing file
Use Python to read() the contents of a file
Starter
Red Task
Create and write to a simple text file using Python.
~~~Evidence~~~
1. Create a program that uses write() mode to create a file that contains some simple text.
Then use the print() function to print the contents of the file.
Then use the print() function to print the contents of the file.
Orange Task
~~~Evidence~~~
2. Write a program to add 3 new lines of text to your file.
- print it, stick it in your book and write a note to explain what you've done
Green Task
Create a program that will simply read() the contents of your file and display it on the screen.
Extension Task
Try these EXERCISES
Blog Post (to finish for hwk)
Add the following notes/code snippets to your blog entitled
'Writing to and Reading a File in Python'
Plenary
Create a program that will simply read() the contents of your file and display it on the screen.
~~~Evidence~~~
3. Write a program that will open() and read() the contents of your file and display it in the screen.
- print it, stick them in your book and write a note to explain what you've done
- print it, stick them in your book and write a note to explain what you've done
Extension Task
Try these EXERCISES
Blog Post (to finish for hwk)
Add the following notes/code snippets to your blog entitled
'Writing to and Reading a File in Python'
Further reading:
Homeowrk
Spend at leasst 30 minutes working on Code Academy - http://www.codecademy.com/learn