Anatomy of a 2D Game using Python’s turtle and Object-Oriented Programming

2D Python game

When I was young, we played arcade games in their original form on tall rectangular coin-operated machines with buttons and joysticks. These games had a resurgence as smartphone apps in recent years, useful to keep one occupied during a long commute. In this article, I'll resurrect one as a 2D Python game and use it… Continue reading Anatomy of a 2D Game using Python’s turtle and Object-Oriented Programming

Write A Football Offside Rule Quiz in Python While Practising Object-Oriented Programming

Offside Rule Python Quiz: silhouette of player kicking the moon

Do you know the offside rule in football*? Or do you want to test whether someone else knows it well enough? Either way, it's time to write an offside rule quiz in Python using object-oriented programming. (*Some of you may call it "soccer") Here's what the quiz will look like. The program presents you with… Continue reading Write A Football Offside Rule Quiz in Python While Practising Object-Oriented Programming

Part 2: Simulating a Tennis Match Using Object-Oriented Programming in Python—Wimbledon Special

How does the likelihood of winning a tennis match change as the likelihood of winning a single point changes? How about the probability of a best-of-five match ending in three sets? Let's have some fun exploring some of these questions using a Python tennis match simulation program. I won't try to factor in all the… Continue reading Part 2: Simulating a Tennis Match Using Object-Oriented Programming in Python—Wimbledon Special

Simulating a Tennis Match Using Object-Oriented Programming in Python—Wimbledon Special Part 1

Simulating a tennis match using object-oriented programming in Python

With Wimbledon underway, I thought of paying homage to the classic tennis tournament with a program simulating a tennis match in Python. I'll use this program to explore several key concepts in Object-Oriented Programming. You'll write a program which will allow you to do two things: Part 1: You can keep the score of a… Continue reading Simulating a Tennis Match Using Object-Oriented Programming in Python—Wimbledon Special Part 1

How Do They Build The Starships in Star Trek? Classes and Objects in Python

Star Trek Spaceships in a Wormhole

With so many new Star Trek series coming out at the moment and in the near future, new and old Trekkies are all asking the same question: How do they build the starships in the Star Trek universe? Or maybe it's just me? This article will boldly go on a journey through classes and objects… Continue reading How Do They Build The Starships in Star Trek? Classes and Objects in Python

Simulating a 3D Solar System In Python Using Matplotlib (Orbiting Planets Series #2)

One of the uses of programming is to help us understand the real world through simulation. This technique is used in science, finance, and many other quantitative fields. As long as the "rules" which govern the real-world properties are known, you can write a computer program that explores the outcomes you get from following those… Continue reading Simulating a 3D Solar System In Python Using Matplotlib (Orbiting Planets Series #2)

Simulating Orbiting Planets in a Solar System Using Python (Orbiting Planets Series #1)

Orbiting Planets in Solar System

One of the many applications of programming in Python is simulating the real world. In some cases, the simulation is a way of solving a problem that would be difficult or impossible to solve using other means. In this article, you'll explore simulating orbiting planets in a solar system using Python. You'll create code that… Continue reading Simulating Orbiting Planets in a Solar System Using Python (Orbiting Planets Series #1)

Bouncing Balls Using Object-Oriented Programming in Python (Bouncing Ball Series #2)

Using Object-Oriented Programming using Python to Simulate Bouncing Balls

In this week's article, I'll discuss an example of using object-oriented programming in Python to create a real-world simulation. I'll build on the code from the first article in the Bouncing Ball Series, in which I looked at the simulation of a single bouncing ball in Python. This article will extend this simulation to many… Continue reading Bouncing Balls Using Object-Oriented Programming in Python (Bouncing Ball Series #2)

Python Instance Variables and Kids on A School Trip

Python instance variables and kids on a school trip

How are Python instance variables different from standard variables? Are they the same thing as data attributes? And what are data attributes? And what do kids on a school trip have got to do with all of this? Questions, questions and more questions. Understanding instance variables in Python tends to happen in stages. First, you… Continue reading Python Instance Variables and Kids on A School Trip