Some Best Practices When Writing Python Functions [Intermediate Python Functions Series #7]

You've covered a lot of material in this Intermediate Python Functions Series. In this final article, you'll read about some best practices in Python functions. This topic is different from the previous ones discussed in this series. You won't get a SyntaxError, TypeError or any other error if you don't follow best practices. Your code… Continue reading Some Best Practices When Writing Python Functions [Intermediate Python Functions Series #7]

Using Type Hints When Defining A Python Function [Intermediate Python Functions Series #6]

You've already covered a lot of ground in this Intermediate Python Functions series. In this article, you'll read about a relatively new addition in Python called type hinting or type annotation. Unlike all the other topics you learnt about in the previous articles, this one will not change the behaviour of the function you define.… Continue reading Using Type Hints When Defining A Python Function [Intermediate Python Functions Series #6]

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

Optional Arguments With Default Values in Python Functions [Intermediate Python Functions Series #3]

Steampunk hat with goggles

We continue our journey through Python functions by looking at optional arguments and default values. In this article, you'll see how you can define a function with an optional argument. A default value is used if the argument is not included in the function call. Overview Of The Intermediate Python Functions Series Here's an overview… Continue reading Optional Arguments With Default Values in Python Functions [Intermediate Python Functions Series #3]

Using Positional Arguments and Named or Keyword Arguments in Python Functions [Intermediate Python Functions Series #2]

Image of steampunk gears used to represent Python functions

In the first article in this Intermediate Python Functions Series, you made sure you got your terminology right. So you know what an argument is. But what are positional arguments and keyword arguments in Python? In this article, you'll see how you can choose to use either of the two in many situations. Later in… Continue reading Using Positional Arguments and Named or Keyword Arguments in Python Functions [Intermediate Python Functions Series #2]

Moving On From The Basics of Python Functions [#1 in Intermediate Python Functions Series]

Steampunk-themed cogs to represent Python functions

Those learning to code learn about functions very early on in their journey. Not only do beginners use Python functions right from their first lesson, but they also learn to define their own Python functions early on. It may be tempting–and in my experience, it's a common pitfall early on–for a relative beginner to think… Continue reading Moving On From The Basics of Python Functions [#1 in Intermediate Python Functions Series]

Mini-Post: Exploring Python Functions Through Experimentation

abstract background with swirls multicolor splashes of paints

Read the docs. Look at the source code. Yes, these are great tips to figure out what's happening underneath the hood. But sometimes you want to do a bit of experimentation and exploration of your own first. It's more fun this way. And sometimes more instructive, too. Here's something I came across today which I… Continue reading Mini-Post: Exploring Python Functions Through Experimentation

Functions in Python are Like a Coffee Machine

Functions in Python are like Coffee Machines - a coffee cup on a desk with computers

Functions in Python are one of those topics for beginners! Most understand what functions are at a basic level. However, there's much more detail and nuance to defining and calling functions in Python. As with most things in coding and Python, there's nothing better than a good analogy to picture what's happening behind the scenes.… Continue reading Functions in Python are Like a Coffee Machine

Sunrise: A Python Turtle Animation Using Named Tuples

Flower in sunrise to illustrate a Python turtle animation using named tuples

You may think the Python turtle module isn't useful for anything. "It's just for kids", is what many think of it. However, this module allows you to explore and experiment with many areas of Python. In this article, you'll write a Python turtle animation of a sunrise scene using named tuples: https://videopress.com/v/OgwI5VyJ?resizeToParent=true&cover=true&preloadContent=metadata&useAverageColor=true As you work… Continue reading Sunrise: A Python Turtle Animation Using Named Tuples