Gradient

Courses

∇\nabla∇The maths behind AI0/72
π\piπMaths0/84
⋆\star⋆AI for everyone0/10
Γ\GammaΓGame theory0/49
py\texttt{py}pyPython for AI0/15
y^\hat{y}y^​Build your own AI0/15
All courses

Tuition

My tuitionOlympiad trackCompetitions

Practice

ProjectsAsk a questionTrain on a GPUExplorationsMaths StoriesUnsolved problemsPlaygroundScience labsMock testsOlympiad

Reference

GlossaryBlogDiscoveries

Class 12 IT tuition · explained simply

Python functions and files

Reading the whole chapter…

The very first time anyone opens this chapter, it takes about a minute to prepare. After that it opens instantly for everyone.

What this chapter covers

  1. Why functions help
  2. Defining and calling functions
  3. Arguments and parameters: positional, default, keyword
  4. Returning values
  5. Scope of variables: local and global
  6. Built-in functions and modules
  7. Exception handling: try, except, finally
  8. Text files: open, read, write, close
  9. Binary files with pickle
  10. CSV files with the csv module
  11. File paths and the with statement