This instruction creates a variable named name and stores text in it:
name = "Maya"Line-by-line explanation
nameis the label we chose.=means “store the value on the right under the name on the left”."Maya"is the value being stored.
Use the name without quote marks to read the stored value:
print(name)Line-by-line explanation
printdisplays a value.namehas no quotes, so Python looks inside the variable.- The output is
Maya.
Assigning a new value is like replacing what is inside the same labeled box:
name = "Noah"Line-by-line explanation
nameis the same label.=performs another assignment."Noah"replaces the earlier value.
Tiny Practice: Make a Labeled Box
Store your favorite color in color, then display it.
Starter template
color = "CHANGE ME"
print(color)Line-by-line explanation
- The first line stores text under
color. - The second line displays the stored value.
Hint
- Replace only CHANGE ME.
- Keep quotes around the color.
- Do not quote
coloron the second line.
Show Solution
color = "blue"
print(color)Line-by-line explanation
- The first line stores
blue. - The second line reads
color. - The output is
blue.