Skip to content

Joseph-T-Gordon

A complete log of all recent projects and skills

Menu
  • About me
  • Posts/Projects
  • Resume/Certifications
Menu

Post #42 (Python Programming) – Functions in python

Posted on April 4, 2023June 26, 2023 by admin

Let’s say you have a piece of code that is repeated multiple times in your program like so.

Code:

print(“I have a message”)

print(“I have a message”)

print(“I have a message”)

Now if you want to change your message you will need to change each instance of it, you can avoid this by creating a function, a function allows you to create a set of code to be ran every time the function is called you use def to create a function like so

Code:

def firstFunction():

print(“I have a message”)

firstFunction()

firstFunction()

firstFunction()

Now if you want to change the message you simply need to alter the function’s code. You can even add further parameters to the function to be used, I will go into further detail on that in my next post!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

© 2025 Joseph-T-Gordon | Powered by Minimalist Blog WordPress Theme