Week 2

Variables: Computer Treasure Boxes

Aim: Make the computer store words and numbers, then use them again.

New coding words

  1. variable
  2. value
  3. name
  4. integer
  5. string

What the coding words mean

  1. variable: A named place where a program stores information. A variable name cannot contain spaces.
  2. value: The information stored inside a variable.
  3. name: The label given to a variable, such as robot_name.
  4. integer: A whole number without a decimal point, such as 8.
  5. string: Text written inside quotation marks, such as "Robo-Pal".
Code along

Store information in variables

Run this program here to see how variables store information. Edit a value and run it again.

Python coding spaceReady to run
.py

Tab indents. Esc then Tab leaves the editor. Ctrl/⌘ + Enter runs your code.

Output (Shell)What your program does
Select Run my code to try this program.
Opening your coding space…Each activity has its own saved code.
Spot the coding words

What is happening in the program?

  1. age = 8 - age is the variable name and 8 is its integer value.
  2. name = "Ada" - name is the variable name and "Ada" is its string value.
  3. age = 9 shows that a variable's value can change.
Mini project

Superhero Profile Card

Invent a superhero, store the facts in variables and print a profile card.

Python coding spaceReady to run
.py

Tab indents. Esc then Tab leaves the editor. Ctrl/⌘ + Enter runs your code.

Output (Shell)What your program does
Select Run my code to try this program.
Opening your coding space…Each activity has its own saved code.

Your mini-project to-do list

0 of 4 completed

Complete these activities in the mini-project editor above. After each change, select Run my code to check your program’s output or drawing.

Save your finished mini project

Select Download my work and save the file as week_2_superhero_profile_card.py. The .py ending tells us that the file contains Python code. Keep this file as a copy of your finished program.

Debugging detective

Chi Opara, your course guide

Knowledge check

Question 1
Python codescore = 10

What is the variable name?

Choose one answer
Question 2
Python codepet = "dog"

What value is stored?

Choose one answer

Your answers are checked in this browser and are not submitted.

How are you getting on so far?

My checklist

Finished Week 2?

This progress is saved only in this browser.