Barcode scanner

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Barcode scanner

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What does a barcode scanner usually shine across a barcode?
A A stream of ink
B A laser beam
2. Which part of a barcode absorbs the light?
A The black lines
B The white gaps
3. Which part of a barcode reflects the light back to the scanner?
A The black lines
B The white gaps
4. What does the scanner's light sensor turn the pattern of reflected light into?
A Digital data
B A printed receipt
5. The barcode itself stores the product's name and current price.
A False: it stores a number that is looked up in a database
B True: all the details are inside the lines

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1barcode scanner AAn input device that shines a laser across a barcode and reads the reflected light to get the product number
2reflected light pattern BThe pattern of light bouncing back from the white gaps but not from the black lines, which the sensor reads
3Black lines absorb light and white gaps reflect it, so the scanner can tell the lines and gaps apart Cblack = absorbs light, white = reflects light
4The product number read from the barcode is looked up in a database to find the product name and price DA barcode only stores a product number. The price is found by looking the number up in a database.
5White gaps absorb light and black lines reflect it Eprice = database.lookup(number)
6The barcode itself stores the price of the product FThis is the wrong way round. Black lines absorb light and white gaps reflect it.

Definitions

barcode scanner

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
Black lines ______ the scanner's light
2.
White gaps _______ light back to the sensor
3.
Sensor turns the pattern into _______ data
4.
Look up the number in a ________ for price
5.
A _____ is shone across the barcode

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A laser SHINES on barcode
B sensor READS reflected light
C black lines REFLECT light
D white gaps REFLECT light
Question 2
A light ← laser.shine()
B pattern ← sensor.write(light)
C number ← decode(pattern)
Question 3
A WHILE items remain
B scan barcode
C price ← lookup(number)
D stock ← stock + 1
E ENDWHILE
Question 4
A scan ← scanner.read()
B number ← decode(scan)
C product ← DB.find(price)
D OUTPUT product.price
Question 5
A IF line IS white THEN
B light ← absorbed
C ELSE
D light ← reflected

Answer Key

Barcode scanner
Section A: Quick Questions
Q1
B — A laser beam
Q2
A — The black lines
Q3
B — The white gaps
Q4
A — Digital data
Q5
A — False: it stores a number that is looked up in a database
Section B: Match the Pairs
Q1
barcode scanner → An input device that shines a laser across a barcode and reads the reflected light to get the product number
Q2
reflected light pattern → The pattern of light bouncing back from the white gaps but not from the black lines, which the sensor reads
Q3
Black lines absorb light and white gaps reflect it, so the scanner can tell the lines and gaps apart → black = absorbs light, white = reflects light
Q4
The product number read from the barcode is looked up in a database to find the product name and price → price = database.lookup(number)
Q5
White gaps absorb light and black lines reflect it → This is the wrong way round. Black lines absorb light and white gaps reflect it.
Q6
The barcode itself stores the price of the product → A barcode only stores a product number. The price is found by looking the number up in a database.
Section C: Definitions
Q1
barcode scanner — An input device that shines a laser across a barcode. Black lines absorb light, white gaps reflect it, and a sensor reads the pattern to get the product number.
Section D: Fill in the Blanks
Q1
Black lines absorb the scanner's light
Q2
White gaps reflect light back to the sensor
Q3
Sensor turns the pattern into digital data
Q4
Look up the number in a database for price
Q5
A laser is shone across the barcode
Section E: Spot the Error
Q1
C — Black lines absorb light, they do not reflect it. The line should be: black lines ABSORB light.
Q2
B — The sensor reads the reflected light pattern, it does not write to it. It should be sensor.read(light).
Q3
D — Each time an item is scanned and sold, stock goes down. It should be stock ← stock - 1.
Q4
C — The database is searched using the product number from the barcode. The price is the result found, so it should be DB.find(number).
Q5
A — The IF branch sets light to absorbed, which only happens for black lines. The condition should be IF line IS black THEN.