3.2 Input, Output and Conditional Statements
Completion requirements
Go through the activity to the end
From Data to Interaction
So far, we've learned how to:
- Store values in variables.
- Work with different data types (numbers, text, etc.).
- Use operators to perform calculations and comparisons.
- Even convert between data types when needed.
But programming isn't just about crunching numbers or transforming data in the background, it's also about interaction. When we write a program, we often need two things:
- Output: information that the program sends out so we can see the result (often on the screen, or written to a file).
- Input: information that comes into the program (usually from a user, a file, or another source).
This back-and-forth is called input/output (I/O).
In this lesson, we'll start with the simplest tools for I/O:
- The
print()function, which sends information out to the screen. - The
input()function, which takes information in from the user.
We'll explore how these functions work and how they connect with the variables and data types you've just learned.