Book a free demo

Beginner ยท ages 8+ ยท print ยท variables ยท strings

Hello world and variables in Python.

Print a message, store things in variables and join them together.

The program

Press Run to see what it prints. Change anything you like, then run it again.

name = "Asha"
age = 10
print("Hello, " + name + "!")
print("Next year you will be", age + 1)
print(name, "is learning Python")
print(name * 3)
Hello, Asha!
Next year you will be 11
Asha is learning Python
AshaAshaAsha

How it works

  1. A variable is a name for a value. name holds text (a string) and age holds a number.
  2. print shows things on the screen. Strings can be joined with +, and a comma prints several things with a space between.
  3. Multiplying a string by a number repeats it: name * 3 prints the name three times.
See the Python path โ†’

Try this

  • Change name and age to your own.
  • Add a line that prints the age next year in a sentence.
  • What happens if you write age + "1"? Python will give an error: numbers and strings do not mix.

Stuck on an error? Read how to debug Python.

Similar ideas

More programs

All programs โ†’

FAQ

Hello world and variables: questions

What does the hello world and variables program do?

Print a message, store things in variables and join them together. It prints: Hello, Asha! / Next year you will be 11 / Asha is learning Python โ€ฆ

Which Python ideas does it use?

print, variables, strings. Beginner level, suitable from about age 8.

How do I run it?

Press Run on this page. To run it on your own computer, install Python 3 and save the code in a file ending in .py. It prints the same thing.

What should I try next?

Change name and age to your own. Add a line that prints the age next year in a sentence. What happens if you write age + "1"? Python will give an error: numbers and strings do not mix.

Start a conversation

Want a teacher to guide the learning?

Tell us the learner's age and what they can already do, and we will suggest a starting point. A parent or guardian can make the enquiry.

  • Tell us the learnerโ€™s age or grade and goals
  • Weโ€™ll suggest a suitable class or learning path
  • Weโ€™ll confirm format, timing and fees with a parent or guardian

For a childโ€™s class, please have a parent or guardian send the enquiry. Avoid sharing passwords or sensitive personal details.

Weโ€™ll use your details only to respond to this request.

Play it, don't just read it

Write some code right now

Free games that need no sign-up. Pick one and play for five minutes.

All free games โ†’
Chat on WhatsApp
Esc

Try