Function Definition

Let's learn the logic and syntax needed to create our first function!

As we discussed earlier, a function performs a certain task and returns a value. This implies that the function will contain an expression.

The Need for Functions

A function can be used repeatedly, which helps us avoid writing redundant code.

Let’s look at a simple program where we calculate and print the double of an integer:

Get hands-on with 1200+ tech skills courses.