Shallow and Deep Copy in Python and How to Use __copy__()

Stormtroopers to show shallow and deep copy in Python

You need to make a copy of an object in a Python program. How difficult can it be? Not very. But you also need to know the difference between shallow and deep copy in Python and decide which one you need. In this article, you'll read about the difference between shallow and deep copy when… Continue reading Shallow and Deep Copy in Python and How to Use __copy__()

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

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)

Practise Using Lists, Tuples, Dictionaries, and Sets in Python With the Chaotic Balls Animation

Using lists tuples dictionaries and sets in Python

One of the early topics covered when learning to code deals with the built-in data structures in Python. Lists are usually learned early on, followed by dictionaries and tuples. Sets are not normally one of the earliest topics covered. However, that's not because they're complex but because they're used less often in Python. Understanding the… Continue reading Practise Using Lists, Tuples, Dictionaries, and Sets in Python With the Chaotic Balls Animation

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)

Python City: Understanding how a Python Program Works (The White Room Series #3)

You've written a Python script or a project containing several modules. You press Run, figuratively or literally. What happens behind the scenes in the microseconds or seconds or minutes it takes for your program to run? You can dive into the details about the internal functioning of Python to learn how a Python program works.… Continue reading Python City: Understanding how a Python Program Works (The White Room Series #3)

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