I/O Operations and String Formatting

Learning PathSkills: Python, Fundamentals, I/O, String Formatting, f-strings, print()

A person presenting a machine that can perform modern Python string interpolation and formatting

Learn how to read keyboard input, display output with print(), and format strings in Python. This path covers the input() and print() built-in functions, stripping characters from strings, f-strings for interpolation, float formatting, and the format mini-language for precise control over your output.

I/O Operations and String Formatting

Learning Path ⋅ 9 Resources

Getting Started With Input and Output

Start by learning Python’s built-in tools for reading user input and displaying output. These tutorials cover the input() and print() functions and how to handle common data types.

Title image for Reading Input and Writing Output in Python (Basic Input, Output, and String Formatting in Python)

Course

Reading Input and Writing Output in Python

In this introductory Python course, you'll learn how to take user input from the keyboard with the built-in function input() and how to display output to the console with the built-in function print().

Title image for Reading User Input From the Keyboard With Python (How to Read User Input From the Keyboard in Python)

Course

Reading User Input From the Keyboard With Python

Master taking user input in Python to build interactive terminal apps with clear prompts, solid error handling, and smooth multi-step flows.

Title image for How to Read Python Input as Integers (How to Read Python Input as Integers)

Tutorial

How to Read Python Input as Integers

Learn how to use Python to get integer input from the user while handling any errors resulting from non-numeric input. This will involve coding your own reusable function built around input().

Working With print() and String Cleaning

Go deeper into the print() function and learn how to clean up strings. You will explore advanced print options and techniques for stripping unwanted characters.

Title image for The Python print() Function: Go Beyond the Basics (The Ultimate Guide to Python Print)

Course

The Python print() Function: Go Beyond the Basics

Learn about the print() function in Python and discover some of its lesser-known features. Avoid common mistakes, take your "hello world" to the next level, and know when to use a better alternative.

Title image for The Python print() Function (The Ultimate Guide to Python Print)

Interactive Quiz

The Python print() Function

Title image for Strip Characters From a Python String (How to Strip Characters From a Python String?)

Course

Strip Characters From a Python String

Use Python's .strip() to remove whitespace or chosen chars. Learn pitfalls, real-world cases, and compare with .lstrip() and .removesuffix().

String Formatting Tools

Explore Python’s string formatting options. Start with a broad overview, then focus on f-strings, float formatting, and the format mini-language for precise control over output.

Title image for Formatting Python Strings (A Guide to the Newer Python String Format Techniques)

Course

Formatting Python Strings

See two items to add to your Python string formatting toolkit. You'll learn about Python's string format method and the formatted string literal, or f-string. You'll learn about these formatting techniques in detail and add them to your Python string formatting toolkit.

Title image for Python 3's F-Strings: An Improved String Formatting Syntax (F-Strings in Python 3.6)

Course

Python 3's F-Strings: An Improved String Formatting Syntax

As of Python 3.6, f-strings are a great new way to format strings. Not only are they more readable, more concise, and less prone to error than other ways of formatting, but they are also faster! By the end of this course, you'll know how and why to start using f-strings today.

Title image for Formatting Floats Inside Python F-Strings (How to Format Floats Within F-Strings in Python)

Course

Formatting Floats Inside Python F-Strings

Learn how to use Python format specifiers within an f-string to allow you to neatly format a float to your required precision.

Title image for Python's Format Mini-Language for Tidy Strings (Python's Format Mini-Language for Tidy Strings)

Tutorial

Python's Format Mini-Language for Tidy Strings

Learn about Python's format mini-language. You'll learn how to use the mini-language to create working format specifiers and build nicely formatted strings and messages in your code.

Congratulations on completing this learning path! You now know how to read user input, display output with print(), clean up strings, and format text using f-strings and Python’s format mini-language.

Continue your Python basics journey with the next learning path:

Learning Path

Python Control Flow and Loops

14 Resources ⋅ Skills: Python, Control Flow, Conditional Statements, Booleans, for Loops, while Loops, enumerate, Nested Loops, break, continue, pass

You might also be interested in these related learning paths:

Got feedback on this learning path?

Looking for real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session. Happy Pythoning!

« Browse All Learning Paths