Python For Kids · Lesson

Input and Output

Taking user input and displaying results.

Lesson 3 of 310 steps

Input and Output is a free Python For Kids lesson on CoddyKit. This is lesson 3 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Python For Kids learning path, and your progress syncs across the web and the CoddyKit app. The Python For Kids course includes 3 lessons in total.

Getting and Showing Data

Input and Output

Welcome to the next step in your Python journey! Today, we'll learn how to take input from users and display results. This will make your programs interactive and dynamic.

Input and Output — illustration 1

What is Input and Output?

  • Input: Any data you enter into your program.
  • Output: The data your program sends out, like messages or results.

By using input and output, your programs can interact with users and respond to their actions.

Taking User Input

To get input from a user, you can use the input() function. This allows the program to ask questions and receive answers.

# Asks the user for their name and stores it in the variable 'name'
name = input("What is your name? ")

Displaying Output

To show information to the user, use the print() function. This will display messages or results on the screen.

Example:

# Greets the user by their name
print("Hello, " + name + "!")

Combining Input and Output

You can combine input() and print() to create interactive programs. Let's create a simple greeting program.

Example:

# Takes the user's name
name = input("What is your name? ")

# Greets the user with their name
print("Hello, " + name + "!")

Taking Numerical Input

By default, input() returns data as a string. To work with numbers, you need to convert the input to the appropriate data type.

Example:

# Takes the user's age as a string
age = input("How old are you? ")

# Converts the age to an integer
age = int(age)

# Displays the age
print("You are " + str(age) + " years old.")

Using Float for Decimals

If you need to handle decimal numbers, convert the input to a float.

Example:

# Takes the user's height
height = input("What is your height in meters? ")

# Converts the height to a float
height = float(height)

# Displays the height
print("Your height is " + str(height) + " meters.")

Example Program: Simple Age Calculator

Let's create a program that asks for the user's name and age, then tells them how old they will be next year.

Code:

# Takes the user's name
name = input("What is your name? ")

# Takes the user's age as a string
age = input("How old are you? ")

# Converts the age to an integer
age = int(age)

# Calculates the next age
next_age = age + 1

# Displays the result
print("Hello, " + name + "! Next year, you will be " + str(next_age) + " years old.")

Great Job!

You've learned how to take input from users and display results in Python. This makes your programs interactive and fun! Keep practicing by creating your own input and output programs.

Input and Output — illustration 10
Free to start

Learn Python with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
22
Lessons
94

Frequently Asked Questions

Is the “Input and Output” lesson free?

Yes — the full text of “Input and Output” is free to read here on the web. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Python For Kids course, upgrade to CoddyKit PRO. The Python For Kids course includes 3 lessons in total.

What will I learn in “Input and Output”?

Taking user input and displaying results. You practise Python For Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Python For Kids?

No prior experience is required. Python For Kids on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 3 of 3.

How long does the “Input and Output” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Python For Kids lesson?

Yes. Every Python For Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Variables and Data Types
  2. Basic Arithmetic Operations
  3. Input and Output
← Back to Python For Kids