Docstrings
Not met yet
A string on the first line inside a def, a class or a file is a docstring. Python keeps it as __doc__, and help() shows it, so callers can use a function without reading its body. Say what goes in and what comes back. A string anywhere else in the body is just a string.
Try it
main.pyOutput
Press Run and what your program prints shows up here.
Easy to get wrong
- Thinks a string anywhere in a function body is its docstring.
- Thinks a docstring is a comment that Python discards, so the program cannot read it.
Where it comes up
- Password Generator
- Word Counter and Text Analyser
- Quiz App
- Order Book
- Bank Account System
- Library Manager
- Personal Finance App
- NumPy Grade Book
- Census Explorer
- Data Cleaning Pipeline
- Census Pivot Tables
- Weather History Dashboard
- Summary Statistics Report
- Statistics Toolkit
- Linear Algebra Lab
- Calculus for ML
- Data Story
- House Price Predictor
- Exam Score Model
- Diabetes Risk Classifier
- Iris and Penguins Classifier
- Loan Approval Tree
- Customer Segmentation
- Model Evaluation Clinic
- Notebook Reader
- Weather Data Investigation
- Paper Reproduction
- Your Own Project