Python Basics — Input & Output
Chapter 5 — Input & Output
Every useful program needs to communicate with its user — reading input and displaying output. This chapter covers Python’s print() and input() functions, along with powerful string formatting techniques.
What You’ll Learn
| # | Topic | Description |
|---|---|---|
| 1 | print() Function | Basic printing, sep, end, printing to files |
| 2 | input() Function | Reading user input, type casting, validation |
| 3 | String Formatting | % operator, str.format(), alignment |
| 4 | f-Strings | Modern string formatting with f-strings |
| 5 | Format Specifiers | Width, alignment, number formatting |
| 6 | Practice Exercises | 5 hands-on exercises with solutions |
Why This Matters
Input and output (I/O) is how your program interacts with the world. Whether you’re building a calculator, displaying a report, or asking for a password — you need I/O. Python’s f-strings make formatting output clean and readable.