Today I didn't finish just the files input/output unit but I finished the whole entire Python 2 course. Even though this was the very last chapter, it wasn't a review, but it was actually a completely new unit where I learned tons of new syntax and codes.
100% COMPLETE |
LESSONS I DID TODAY |
FINAL EXERCISE
The final review of course consisted of all the new codes I learned, it may look confusing but all this does is opens a new 'text file' kind of and reads it. If the text.txt tab has written 'My Data' it will return as true as stated in the code.
WHAT I LEARNED:
This unit was mainly about how to read/write information from a different file on your computer. Code Academy mentions that all we have been doing is typing codes, and the results come out in the output console. I learned that this process is called file I/O which stands for input/output. And Python already has built-in functions for this.
- The first thing I learned was the open() function. I'm sure the name sounds pretty self-explanatory but basically, this code tells Python to open output.txt in"w" mode which stands for "write." Doing this opens the file in write mode.
open() code |
- The third thing I learned was a bit confusing, but I'm pretty sure it opens and closes files for you, as Python usually does all the work. File objects contain a special pair of built-in methods.
with and as syntax |
WHAT I WILL BE DOING NEXT TIME:
So now that I have finished the entire course, I was thinking of doing a final game such as creating a small program or even game to finish off.
I will be taking steps and start thinking about what to do and then start on it next time.
No comments:
Post a Comment