🐸

Variables

Python Basics

Goal · +50 XP
|

Variables

In Python, a variable is just a name that points to a value.

You can think of it as putting a label on a box. The label is the name, the thing inside is the value.

Example

message = "Hello Hoppy"
print(message)
Think about it

When you write message = "Hello Hoppy", you are making the name message point to the string "Hello Hoppy".

Your Mission

1
Create a variable x

Create a variable named x.

2
Set it to 10

Put the number 10 inside it.

3
Print it

Use print to print it.

Hint

When you are done, click the Run button in the top right to see the output.

标准答案 · Suggested Solution
点击展开

A simple solution that fully matches the requirements is:

x = 10

print(x)

You can also print "Hello Hoppy" before printing x. As long as x ends up being 10, the check will pass.

高级技巧 · Advanced Tips
想更进一歩?点击展开

Even from the very first lesson, you can start building good habits:

  • Use meaningful names like age or score, instead of a or b.

  • Do one thing per line: assignment on one line, printing on another line.

  • Later, when you learn type hints, you can write x: int = 10 to make the intent explicit.

You do not need all the advanced features now. The key is to write code that is easy to read from day one.

main.py
Loading...
Terminal
Ready to run...