Python Notes #6 Functions
Hi Everyone, Today I'm doing functions I have kept this as its own blog as this is a bit of a tougher topic and for my own memory I'd like to be able to find this easily if I ever had to review python notes. A function is a chunk of reusable code this means that the code can be created and then passed anywhere within the code later on. This is how a function works - def name(first, last): print("Please enter name: ") print(f"Your name is: {first} {last}") name("Iain", "H") In this chunk of code I pass the parameters first & last within the function - from here I create a print statement asking for my name, notice how in the second print statement I am passing the parameters first and last (represented by the curly braces) and lastly I call the function name and define the values within the brackets - with the last statement now first will = 'Iain' and last will = 'H'. This code produces this output - Please enter