Knaph

Files in code

Reading and writing files, so a program can keep data after it stops - open with a mode, with to close it, lines read one by one, and the csv module for tables.

Depth 1 · Foundation

You can write, append to and read a text file with open and with, choose the right mode, loop over its lines and strip them, handle a missing file with try and except, and read and write CSV with the csv module.

Sign in to prove what you know with a short quiz, see how deep you've gone, and earn XP for it.

Sign in with Google

Depths of understanding

  1. 1

    Foundation

    You can write, append to and read a text file with open and with, choose the right mode, loop over its lines and strip them, handle a missing file with try and except, and read and write CSV with the csv module.

Your path here

What's still between you and Files in code, depth 1, in the order you can learn it.

  1. 1ProgramDepth 1 · Foundation · Program Basics
  2. 2ExpressionDepth 1 · Foundation · Program Basics
  3. 3Variables in codeDepth 1 · Foundation · Program Basics
  4. 4Program stateDepth 1 · Foundation · Program Basics
  5. 5Input and outputDepth 1 · Foundation · Program Basics
  6. 6Functions in codeDepth 1 · Foundation · Functions
  7. 7Return valuesDepth 1 · Foundation · Functions
  8. 8BooleansDepth 1 · Foundation · Control Flow
  9. 9ConditionalsDepth 1 · Foundation · Control Flow
  10. 10LoopsDepth 1 · Foundation · Control Flow
  11. 11Accumulator patternDepth 1 · Foundation · Control Flow
  12. 12Floating-point numbersDepth 1 · Foundation · Data Types
  13. 13Basic typesDepth 1 · Foundation · Data Types
  14. 14Character encodingDepth 1 · Foundation · Data Types
  15. 15StringsDepth 1 · Foundation · Data Types
  16. 16Type conversionDepth 1 · Foundation · Data Types
  17. 17ExceptionsDepth 1 · Foundation · Writing Correct Code
  18. 18Modules and importsDepth 1 · Foundation · Organizing Programs
  19. 19Files in codeDepth 1 · Foundation · Organizing Programs

Where it fits