teachwithict
  • Home
  • Teaching & Learning
    • Tools for Teachers >
      • Web 2.0 >
        • Top 10 Web 2.0 Tools
        • Classroom Response Tools
      • Quiz Tools
      • Classroom Management Tools
      • Software >
        • Media Conversion Tools
        • Application Software
      • Multimedia >
        • Free Music
    • Digital Leaders >
      • Digital Leaders Blog >
        • DL Archive
      • DL Tips
      • Quotes
      • Links
    • BYOD
    • Flipped Learning >
      • Flipped Classroom vs. Blended Classroom
    • Gamification >
      • Gamification vs. Game Based Learning vs. Game Design
    • Game Based Learning >
      • Minecraft >
        • Minecraft in Education
        • Minecraft Lesson Ideas
        • Minecraft Literacy
        • Minecraft Coding Tutorials >
          • Minecraft Code Builder Setup
          • Minecraft Code: Walking on Air
          • Minecraft Code: Hello World
          • Minecraft Code: Functions
          • Minecraft Code: Rainbow
          • Minecraft Code: Skyscraper
          • Minecraft Pixel Art
    • The magic of >
      • The magic of Computing
      • The magic of Maths
      • The magic of Science
      • The magic of Literacy
    • Breakout Edu
    • PLN Challenge >
      • Covering your backside
      • Twitter Challenge >
        • Challenge 1
        • Challenge 2
        • Challenge 3
        • Tips for staying safe on Twitter
        • Tips for hosting Edu Twitter Chats
        • Tips for taking part in Twitter chats
        • How to storify a chat
        • How to schedule Tweets
        • Twitter Lists
        • It's all about the hashtag! Essential chats for educators
      • Facebook Challenge >
        • Challenge 4
        • Challenge 5
        • Challenge 6
        • Tips for staying safe on Facebook
      • Google Challenge >
        • Challenge 7
        • Challenge 8
        • Challenge 9
      • Pinterest Challenge >
        • Challenge 10
        • Challenge 11
        • Challenge 12
        • Tips for using Pinterest
      • Blog Challenge >
        • Challenge 13
        • Challenge 14
        • Challenge 15
        • How to create a classroom blog
      • Staffrm Challenge >
        • Challenge 16
        • Challenge 17
        • Challenge 18
      • Skype Challenge >
        • Challenge 19
        • Challenge 20
        • Challenge 21
      • Edmodo Challenge >
        • Challenge 22
        • Challenge 23
        • Challenge 24
      • TeachMeet Challenge >
        • Challenge 25
        • Challenge 26
        • Challenge 27
      • In-school challenge >
        • Challenge 28
        • Challenge 29
        • Challenge 30
      • 30 ways to grow your PLN
    • T&L Blog
  • Computing
    • Computing Blog >
      • GCSE Computer Science
      • General
    • CPD >
      • Blocks to Code
      • Tutorials >
        • How to embed Flash into PowerPoint
        • How to embed YouTube videos in to PowerPoint
        • How to create a wiki
        • How to create a classroom blog
    • Teaching Computer Science >
      • Schemes of Work
      • Programming Resources
      • Theory
      • Posters
    • Theory Lessons >
      • Theory Tests
      • Computer Hardware >
        • Input / Output
        • CPU
        • LMC
        • Storage Devices
        • Memory (RAM / ROM)
      • Binary Lessons >
        • Units of Data
        • Binary Representation
        • Binary Representation of Images
        • Binary Representation of Characters
        • Binary Representation of Sound
        • Binary Representation of Instructions
        • Binary Addition
        • Hexadecimal
      • Software >
        • Operating System
        • Types of Software
        • Utility Software
      • Programming >
        • Flowcharts
    • Game Design
    • App Creation
    • Digital Literacy >
      • Social Media (Good or Bad thing?)
      • Cyberbullying
      • Staying Safe Online
    • ICT Strand >
      • Spreadsheet Modelling
      • Superhero Movie Trailer
      • PowerPoint Task
      • Paint 3D Tutorial
    • Programming Lessons >
      • Microbit >
        • Magic 8 Ball
        • Harry Potter Sorting Hat
        • Music
        • Music (Festive)
        • Quick Start Guide
        • Microbit Simulator
      • TouchDevelop >
        • TouchDevelop Challenge
        • Scheme of Work
        • TouchDevelop Lessons >
          • 8 bit challenge
          • Turing Test
          • Turtle Power
          • 8 Ball
          • Under the hood
        • Tutorials
      • Raspberry Pi >
        • Networking the Pi
        • Minecraft Pi
        • Harry Potter Sorting Hat >
          • Harry Potter Sorting Hat (GPIO)
        • Raspberry Pi LTSP (Networked Classroom)
        • Astro Pi
      • Scratch
      • Python >
        • Chatbot
        • Coding Golf
        • Magic 8 ball
        • Python Mad Libs
        • Shakespearean Insult Generator >
          • Shakespearean Insult Generator Part 2
        • Sorting Hat
      • Little Man Computer
      • Hour of Code >
        • HoC 8-Bit Challenge
  • 21 Things
  • Microbit
    • Physical Computing >
      • micro:bit LEDs
  • About
  • Blog
  • Home
  • Teaching & Learning
    • Tools for Teachers >
      • Web 2.0 >
        • Top 10 Web 2.0 Tools
        • Classroom Response Tools
      • Quiz Tools
      • Classroom Management Tools
      • Software >
        • Media Conversion Tools
        • Application Software
      • Multimedia >
        • Free Music
    • Digital Leaders >
      • Digital Leaders Blog >
        • DL Archive
      • DL Tips
      • Quotes
      • Links
    • BYOD
    • Flipped Learning >
      • Flipped Classroom vs. Blended Classroom
    • Gamification >
      • Gamification vs. Game Based Learning vs. Game Design
    • Game Based Learning >
      • Minecraft >
        • Minecraft in Education
        • Minecraft Lesson Ideas
        • Minecraft Literacy
        • Minecraft Coding Tutorials >
          • Minecraft Code Builder Setup
          • Minecraft Code: Walking on Air
          • Minecraft Code: Hello World
          • Minecraft Code: Functions
          • Minecraft Code: Rainbow
          • Minecraft Code: Skyscraper
          • Minecraft Pixel Art
    • The magic of >
      • The magic of Computing
      • The magic of Maths
      • The magic of Science
      • The magic of Literacy
    • Breakout Edu
    • PLN Challenge >
      • Covering your backside
      • Twitter Challenge >
        • Challenge 1
        • Challenge 2
        • Challenge 3
        • Tips for staying safe on Twitter
        • Tips for hosting Edu Twitter Chats
        • Tips for taking part in Twitter chats
        • How to storify a chat
        • How to schedule Tweets
        • Twitter Lists
        • It's all about the hashtag! Essential chats for educators
      • Facebook Challenge >
        • Challenge 4
        • Challenge 5
        • Challenge 6
        • Tips for staying safe on Facebook
      • Google Challenge >
        • Challenge 7
        • Challenge 8
        • Challenge 9
      • Pinterest Challenge >
        • Challenge 10
        • Challenge 11
        • Challenge 12
        • Tips for using Pinterest
      • Blog Challenge >
        • Challenge 13
        • Challenge 14
        • Challenge 15
        • How to create a classroom blog
      • Staffrm Challenge >
        • Challenge 16
        • Challenge 17
        • Challenge 18
      • Skype Challenge >
        • Challenge 19
        • Challenge 20
        • Challenge 21
      • Edmodo Challenge >
        • Challenge 22
        • Challenge 23
        • Challenge 24
      • TeachMeet Challenge >
        • Challenge 25
        • Challenge 26
        • Challenge 27
      • In-school challenge >
        • Challenge 28
        • Challenge 29
        • Challenge 30
      • 30 ways to grow your PLN
    • T&L Blog
  • Computing
    • Computing Blog >
      • GCSE Computer Science
      • General
    • CPD >
      • Blocks to Code
      • Tutorials >
        • How to embed Flash into PowerPoint
        • How to embed YouTube videos in to PowerPoint
        • How to create a wiki
        • How to create a classroom blog
    • Teaching Computer Science >
      • Schemes of Work
      • Programming Resources
      • Theory
      • Posters
    • Theory Lessons >
      • Theory Tests
      • Computer Hardware >
        • Input / Output
        • CPU
        • LMC
        • Storage Devices
        • Memory (RAM / ROM)
      • Binary Lessons >
        • Units of Data
        • Binary Representation
        • Binary Representation of Images
        • Binary Representation of Characters
        • Binary Representation of Sound
        • Binary Representation of Instructions
        • Binary Addition
        • Hexadecimal
      • Software >
        • Operating System
        • Types of Software
        • Utility Software
      • Programming >
        • Flowcharts
    • Game Design
    • App Creation
    • Digital Literacy >
      • Social Media (Good or Bad thing?)
      • Cyberbullying
      • Staying Safe Online
    • ICT Strand >
      • Spreadsheet Modelling
      • Superhero Movie Trailer
      • PowerPoint Task
      • Paint 3D Tutorial
    • Programming Lessons >
      • Microbit >
        • Magic 8 Ball
        • Harry Potter Sorting Hat
        • Music
        • Music (Festive)
        • Quick Start Guide
        • Microbit Simulator
      • TouchDevelop >
        • TouchDevelop Challenge
        • Scheme of Work
        • TouchDevelop Lessons >
          • 8 bit challenge
          • Turing Test
          • Turtle Power
          • 8 Ball
          • Under the hood
        • Tutorials
      • Raspberry Pi >
        • Networking the Pi
        • Minecraft Pi
        • Harry Potter Sorting Hat >
          • Harry Potter Sorting Hat (GPIO)
        • Raspberry Pi LTSP (Networked Classroom)
        • Astro Pi
      • Scratch
      • Python >
        • Chatbot
        • Coding Golf
        • Magic 8 ball
        • Python Mad Libs
        • Shakespearean Insult Generator >
          • Shakespearean Insult Generator Part 2
        • Sorting Hat
      • Little Man Computer
      • Hour of Code >
        • HoC 8-Bit Challenge
  • 21 Things
  • Microbit
    • Physical Computing >
      • micro:bit LEDs
  • About
  • Blog
Search by typing & pressing enter

YOUR CART

Anyone for a game of 'Code Golf'? - FORE!

Like this lesson? Share it with your followers by clicking on the image below.

Picture
Anyone who has taught Computing / Computer Science will know that the 'coding and programming' strand can sometimes feel like a very dry topic, especially for young children. One way to inject some fun into your coding lessons is to gamily them!

For those new to the concept, gamification is the process of introducing game-like elements into a traditionally non-gaming contexts to make them more fun and engaging. Gamification strategies include elements such as gamifying grading, incentivizing students with rewards and adding competitive elements such as leaderboards.

One strategy that exemplifies the concept of gamification in the teaching of coding is a game called 'Code Golf'.


What is 'Code Golf'?


I came across the idea of Code Golf at a Computing At School (CAS) conference last summer and have been experimenting with it ever since. The idea is simple, participants are given a problem (or working solution) and are challenged to solve it using the fewest lines of code.

The term Code Golf is derived from the similarity of its scoring system to that of conventional golf, where participants aim to achieve the lowest score possible.


Why Code Golf?

The idea behind Code Golf is to encourage efficient use of code. At GCSE / A-Level, students are required to make efficient use of code in order to access higher grades / mark bands. Efficient code also uses less RAM, compiles quicker and uses up less storage space. Students can use a combination of features such as loops (For, While, Repeat) or sub-routines to achieve their optimised code however, readability and usability must not be sacrificed at the expense of code optimisation therefore, white space and comments do not count as lines; we still want to encourage students to break up and comment their code so that it is comprehensible to others, easier to debug and easy for others to re-use.


Types of Code Golf

There are two main ways to play Code Golf. The first way requires students to solve a given problem using the fewest lines of code. The second method, which requires a little more preparation from the teacher, requires the students to optimise a given working solution. In both methods, the challenge is for the students to create a solution using the least amount of code. To add a little extra challenge, the teacher can add a Par value (or target number), with the Par being the optimal number of lines of code. This Par value can be altered for different levels of ability (similar to the 'handicap' system in conventional golf) thus allowing the teacher to differentiate the lesson.


Example:

The following is an example of a simple 'Par Challenge'. In this example, students are challenged to create a square using the Python turtle library using 6 lines of code (Par 6).
Working, but inefficient, solution for creating a square in Python using 11 lines of code.
More efficient solution for creating a square using 6 lines of code (or Par 6).

Example Lesson

Learning Objectives:

  • Understand and use sequence in an algorithm
  • Understand and use iteration in an algorithm (FOR and WHILE loops)


Curriculum Mapping:

KS2:
  • Design, write and debug programs that accomplish specific goals; solve problems by breaking them into smaller parts. Select, use and combine a variety of software on a range of digital devices to design and create a range of programs.
  • Use sequence, selection and repetition in programs; work with variables and various forms of input and output
  • Use logical reasoning to explain how some simple algorithms work; detect and correct errors in algorithms and programs


KS3:
  • Use two or more programming languages, at least one of which is textual, to solve a variety of computational problems.


What you will need:
  • Python 3 (Click here to download the latest version - FREE)
  • Mark Clarkson's introduction to Python booklet (For instructions on using the Turtle library)


Challenge

Instruct students to open Mark Clarkson's introduction to Python booklet (See link above) and ask them to attempt the Turtle tutorials. Once the students have got the hang of turtle, explain to them that they are going to compete in a game of 'Coding Golf'. Hand out the challenge (See PowerPoint below) and explain to students that challenge is to solve each of the tasks using the fewest of lines of code possible.
Picture


​Resources

Click on the link below to download the PowerPoint.
coding_golf.pptx
File Size: 582 kb
File Type: pptx
Download File

Scorecard:
scorecard.xlsx
File Size: 11 kb
File Type: xlsx
Download File


Rules

To make the challenge fair and consistent, I recommend that you set some competition rules. Here are the rules I use:

  1. Blank lines don't count as lines of code.
  2. Comments don't count as lines of code. (We want to encourage the students to comment their code).
  3. Import turtle, import random etc. do not count as lines of code.
  4. Everything else counts.

Useful Links

​​Stack Exchange (Code Golf) - Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required. 
Book of Programming Challenges - Book of programming challenges, ideal for Code Golf , courtesy of Stuart Lucas (Requires sign up to Computing At School - FREE)

You may also be interested in:
  • Python Shakespearean insult generator
  • Python Mad Libs
  • Python Chat Bot
  • Python Sorting Hat
  • Python Magic 8-Ball ​

Tags: programming language python, python programming language, python coding language, programming languages python, python code language, python programming language example, what is the python programming language, python scripting, language tutorial, what type of programming language is Python, python class, python how to learn, learn python, learn python from scratch, where to learn Python, coding on computer, computer coding,  best place to learn coding online, online coding, online code, computer programming and Coding, hour of code program, computer science degree programs, programs for computer science, what does coding mean in computers, how does computer code work, what is computer programmer.
Powered by Create your own unique website with customizable templates.