Introduction

Published

2023-07-31

This chapter introduces functions. Functions are a fundamental building block for code in all programming languages (though they may go by different names, depending on context).

Learning objectives

  • You will learn how to write simple functions in Python, using def.
  • You will learn how to use functions in your code.
  • You will learn that indentation is syntactically meaningful in Python (unlike many other languages).
  • You will learn how to use functions (and constants) in Python’s math module, such as square root and sine.
  • You will expand on and solidify your understanding of topics presented in earlier chapters.

Terms and keywords introduced

  • argument
  • call or invoke
  • def keyword
  • dot notation
  • formal parameter
  • function
  • import
  • keyword
  • local variable
  • module
  • pure and impure functions
  • return keyword
  • return value
  • scope
  • shadowing
  • side effect

Original author: Clayton Cafiero < [given name] DOT [surname] AT uvm DOT edu >

No generative AI was used in producing this material. This was written the old-fashioned way.

This material is for free use under either the GNU Free Documentation License or the Creative Commons Attribution-ShareAlike 3.0 United States License (take your pick).