Repaso
EspaƱol
PythonFoundationsPY-62

What does age = 30 do in Python?

Options

  1. It compares age with 30 and prints True or False on screen
  2. It creates a variable called age that refers to the value 30 (Correct option)
  3. It defines a function called age that always returns 30
  4. It prints the number 30 on the screen and stores nothing

Answer

Creates a variable named age that refers to the value 30

Why

A variable is a name that points to a value, so you can use the value later.

The single = means assign (store), not compare. Comparing uses ==.

In Python you do not declare the type. age simply refers to the integer 30, and later it could refer to something else.

Remember

variable = value stores the value under a name.

Key terms

Practice this question in Repaso