Document Type

Conference Proceeding

Publication Date


Publication Title

EDULEARN22 Proceedings, 14th International Conference on Education and New Learning Technologies



Publisher Name

IATED Academy

Publisher Location

Valencia, Spain


Magic can be used in project-based instruction to motivate students and provide a meaningful context for learning computer programming. This work describes several magic programs of the “Choose a Number” and “Pick a Card” varieties, making connections to underlying computing concepts.

Magic tricks presented as demonstrations and programming assignments elicit wonder and captivate students’ attention, so that students want to understand and replicate the work to show it to friends and family members. Capturing student interest and curiosity motivates them to learn the underlying programming concepts.

Two “Choose a Number” programs are shown where the computer is able to identify a user’s choice among many alternatives:

1. Magic Letter: A table of numbers with associated random letters is displayed. Participants make choices and the computer identifies their chosen letter.

2. Number Boxes: The user chooses a secret number, for example the age at which their business becomes successful and is sold. The user indicates which boxes displayed on the screen contain the secret number, and the computer then identifies the number.

Two “Pick a Card” varieties are shown, where board pieces represent cards, the user selecting one of them that the computer later identifies:

1. Secret Tile: A grid of black and white tiles is displayed, where the computer verifies that the magician can identify which secret tile selected by a volunteer has been flipped.

2. Twenty-one Card Magic: Twenty-one cards are selected from a shuffled deck and displayed faceup, with a volunteer choosing a secret card. After repeated stacking and re-dealing, the secret card is identified.

These examples illustrate computing concepts and can be used in classroom explanations and programming assignments. Links are given to online playable versions, assignment descriptions, and magic-themed resources in computing.


ISBN: 978-84-09-42484-9


Author Posting. © 2022, IATED. This is the author's version of the work. It is posted here by permission of IATED. The definitive version can be found in EDULEARN22 Proceedings, 14th International Conference on Education and New Learning Technologies, pages 3240-3248, July 2022.

Creative Commons License

Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 License
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 License.

ReedG2022slides.pptx (1433 kB)
Conference presentation slides