Syntactic generation of practice novice programs in python

Research output: Chapter in Book/Report/Conference proceedingConference contributionpeer-review

10 Citations (Scopus)


In the present day, computer programs are written in high level languages and parsed syntactically as part of a compilation process. These parsers are defined with context-free grammars (CFGs), a language recogniser for the respective programming language. Formal grammars in general are used for language recognition or generation. In this paper we present the automatic generation of procedural programs in Python using a CFG. We have defined CFG rules to model program templates and implemented these rules to produce infinitely many distinct practice programs in Python. Each generated program is designed to test a novice programmer’s knowledge of functions, expressions, loops, and/or conditional statements. The CFG rules are highly generic and can be extended to generate programs in other procedural languages. The resulting programs can be used as practice, test or examination problems in introductory programming courses. 500,000 iterations of generated programs can be found at: A survey of 103 students’ perception showed that 93.1% strongly agreed that these programs can help them in practice and improve their programming skills.

Original languageEnglish
Title of host publicationICT Education - 47th Annual Conference of the Southern African Computer Lecturers’ Association, SACLA 2018, Revised Selected Papers
EditorsHussein Suleman, Stefan Gruner, Salah Kabanda
PublisherSpringer Verlag
Number of pages15
ISBN (Print)9783030058128
Publication statusPublished - 2019
Event47th Annual Conference of the Southern African Computing Lecturers Association, SACLA 2018 - Gordon's Bay, South Africa
Duration: 18 Jun 201820 Jun 2018

Publication series

NameCommunications in Computer and Information Science
ISSN (Print)1865-0929


Conference47th Annual Conference of the Southern African Computing Lecturers Association, SACLA 2018
Country/TerritorySouth Africa
CityGordon's Bay


  • Context-free grammar applications
  • Novice programmers
  • Practice Python programs
  • Program synthesis
  • Synthesis of things

ASJC Scopus subject areas

  • General Computer Science
  • General Mathematics


Dive into the research topics of 'Syntactic generation of practice novice programs in python'. Together they form a unique fingerprint.

Cite this