PROGRAMMING_atom_finder
PROGRAMMING_atom_finder
Learning Objectives
Activity Overview
List of atoms used in the game: Hydrogen, Helium, Carbon, Nitrogen, Oxygen,
Fluorine, Neon, Sodium, Magnesium, Aluminium, Silicon, Phosphorus, Sulfur,
Chlorine, Argon, Potassium, Calcium, Iron, Cobalt, Nickel, Copper, Zinc, Silver,
Tin, Antimony, Iodine, Platinum, Gold, Mercury, Lead.
Game Rules
Example:
Discussion Points
Important Terms
AMEND A PROGRAM
Lesson Objectives
Spiral Back
• Open the Atom List program and read through the code.
• The program is divided into three sections:
i. List of atoms (stores atomic elements)
iii. Main program (displays the menu and executes user choices)
List of Atoms
Procedure Definitions
• This part of the program contains functions that define how operations
(adding/removing items) are performed.
Main Program
• It:
atoms.append(name)
if choice == "R":
atoms.remove(name)
Option Function
A Append an atom to the list
R Remove an atom from the list
P Print the entire list
X Exit the program
Example:
• If you type "A", the program will ask for an atom name and
add it to the list.
• If you type "R", it will ask for an atom name and remove it.
• If you type "P", it will print the entire list.
• If you type "X", the program exits.
Example of a Header
if choice == "A":
Example of a Body,
atoms.append(name)
• A loop:
Types of Loops
if choice == "A":
atoms.append(name)
print(name, "has been added to the list")