Search⌘ K
AI Features

Solution: About You

Explore how to use variables in Python to store text and numbers, and learn to print them together in meaningful sentences. This lesson helps you practice combining code elements with the print function, forming a foundation for interactive programming.

We'll cover the following...

In this example, we’re teaching Python to remember information using variables, and then print that information together in a sentence.

name = "Alex"
age = 22
print("Hi, my name is", name, "and I’m", age, "years old.")
  • name = "Alex" stores the text "Alex" in a variable called name.

  • age = 22 stores the number 22 in a variable called age.

  • The print() function displays the message.

  • Inside print(), we use commas to separate text and variables, Python automatically adds spaces between them.

Python
name = "Alex"
age = 22
print("Hi, my name is", name, "and I’m", age, "years old.")