Python Functions: Using Built-in Functions and Creating Functions

In the Variables, Data Types, and Lists in Python course, we used commands such as print(), len(), int(), type(), and round(). We call these statements functions.

In this functions fundamentals lesson, you’ll learn how to speed up your workflow using functions. You will also learn how to create your own functions and use built-in Python functions. You will learn concepts such as the structure of a function, parameters and arguments, and writing functions that use a return statement.

When writing a program, you could just keep rewriting the same code, but that would be tedious, and it would result in an unnecessarily large program. Functions are self-contained routines that perform a specific task that you can incorporate into your program. After declaring the function, you can use the function anytime to save time and resources. A function displays these patterns: it takes an input, transforms the input, and returns an output.

While learning about functions, you’ll create your own functions, including one to create a frequency table that you’ll build in the following lesson: Python Functions: Arguments, Parameters, and Debugging. For more information on frequency tables, you might want to check out our Python Dictionaries and Frequency Tables lesson.

As you go through this lesson, you’ll get to apply what you’ve learned from within your browser; there’s no need to use your own machine to do the exercises. The Python environment inside of this course includes answer-checking to ensure you’ve fully mastered each concept before learning the next.

Objectives

  • Learn how to define the structure of a function
  • Learn how to create your own functions
  • Learn how to employ built-in functions
  • Learn how to return values from a function call

Lesson Outline

  1. Functions
  2. Built-in Functions
  3. Creating Our Own Functions
  4. The Structure of a Function
  5. Parameters and Arguments
  6. The Return Statement
  7. Review
  8. Takeaways

Get started for free

No credit card required.

Already have an account? Sign in →

By creating an account you agree to accept our terms of use and privacy policy.