Introduction to Python
  • Introduction
  • Preface
  • Background
  • Installing Python
  • Getting Started
  • Basics
    • More Printing
    • Strings
    • Numbers
    • Exercises
    • Comments
  • Variables
    • Operators
    • Type Conversion
    • Exercises
    • A Brief Introduction to Lists
    • Game Exercise
  • Human Input
  • Functions
    • First Functions
    • Why Functions
    • Exercises
  • Indentation
  • Decisions
    • Booleans
    • Logical Operators
    • If Statements
    • Elif and Else Statements
    • Exercises
    • Rock, Paper, Scissors
    • Game Exercise
    • Game Exercise 2
  • Lists
  • Loops
    • For Loops
    • While Loops
  • More Data Structures
    • Tuples
    • Dictionaries
  • Pygame
  • Extra Content
    • Computers and Code
    • More About Python
    • For Loops with Range
    • List Slicing
Powered by GitBook
On this page

Functions

So we're going practice functions until we dream them at night. Functions are blocks of code which contains a specific set of instructions when called. What do you mean "when called"? Well after we create a function we have to explicitly use the function so that the code will run.

print('Hey, I\'m the Pink Power Ranger') # We call the print function

In the above example we call the print function. A function is called by using it's name and providing any arguments i.e. inputs, in this case the greeting being printed. After we create our functions, we'll have to call them in the same way we call the print function.

PreviousHuman InputNextFirst Functions

Last updated 6 years ago