Menu
Coddy logo textTech

What is a function?

Lesson 5 of 19 in Coddy's Into the Past || Complete Beginner for Python Strings course.

Python Functions

 

A function in python is a piece of code that can be reused at anytime

 

A function has 5 parts, 4 must have a one optional:

  • keyword def
  • name of function
  • parentheses ()
  • colon :
    • and the stuff inside the function (optional)
challenge icon

Challenge

Easy

Let's take a look:

def greeting():
     return "hi"

Now run the code that is given to you in the code editor and see for yourself

Try it yourself

def greeting():
    return "hi"

All lessons in Into the Past || Complete Beginner for Python Strings