A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Basic Input and Output

College Depth 72 in the knowledge graph ☐ I know this ☆ Set as goal
592topics build on this
321prerequisites beneath it
See this on the map →
Variables and AssignmentPrimitive Data Types+2 more→→File I/O BasicsFile System Concepts+1 more
I/O print input console user interaction

Core Idea

Programs communicate with users through input and output operations. Output (e.g., print) sends text or values to the console; input (e.g., input() or scanf) reads text typed by the user. All console input arrives as text (strings), so numeric input must be converted to the appropriate type before arithmetic. Clear, informative output is a form of program documentation for the user.

How It's Best Learned

Write interactive programs that prompt for input, compute something, and display results. Deliberately forget type conversion and observe the resulting error.

Common Misconceptions

Explainer

You already know how to store data in variables and work with different data types. Input and output (I/O) are how your program communicates with the outside world — specifically, how it displays results to the user and receives data from them. Without I/O, a program computes in silence: it might calculate the answer to a problem, but no one would ever see it.

Output is the simpler side. In Python, `print()` sends text to the console. In C, `printf()` does the same. You can output literal strings (`print("Hello")`), variable values (`print(x)`), or combinations using string formatting or concatenation. The key idea is that output converts your program's internal data into a human-readable text representation. When you print an integer, the language converts the binary number in memory into a sequence of digit characters on screen. This conversion happens automatically for basic types, but understanding that it occurs helps you troubleshoot when output looks unexpected.

Input is where most beginners encounter their first surprising bug. When a user types `42` at the keyboard, the program receives the *string* `"42"` — two characters, not a number. This is because the console deals exclusively in text. If you want to do arithmetic with that value, you must explicitly convert it: `int("42")` in Python, `atoi()` or `scanf("%d", ...)` in C. Forgetting this conversion is the single most common I/O mistake. Your program will either crash with a type error or silently produce wrong results by concatenating strings instead of adding numbers. The rule is simple: all console input arrives as text, and you are responsible for parsing it into the type you need.

Good I/O also means writing clear prompts that tell the user what to type. A prompt like `"Enter your age: "` (with a trailing space) is far better than a blank cursor that leaves the user guessing. Think of output as your program's voice and input as its ears — together they create the conversation between human and machine. As you progress, you will learn to read from files and network connections, but the console I/O patterns you build now — prompt, read, convert, compute, display — are the foundation for all interactive programming.

Practice Questions 5 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Type Systems and Type Safety → Type Conversion and Casting → Basic Input and Output

Longest path: 73 steps · 321 total prerequisite topics

Prerequisites (4)

Leads To (3)