logo
How it worksCoursesResearch CommunitiesBenefitsAbout Us
Schedule Demo
Learn Before
  • Functions in Python

    Concept icon
Code

Defining Functions in Python

New functions can be created with the keyword def, as such:

def sub(x, y): return x - y def add(x, y): return x + y def square(x): return x ** 2

0

1

Updated 2021-08-18

Contributors are:

Alex Y
Alex Y
🏆 10
Sam Winter
Sam Winter
✔️ 1

JT

Jennifer Tso
✔️ 1

Who are from:

University of Michigan - Ann Arbor
University of Michigan - Ann Arbor
🏆 11
University of California, Davis
University of California, Davis
✔️ 1

References


  • Runestone: Foundations of Python Programming

Tags

Data Science

Related
  • Defining Functions in Python

  • Format of Functions in Python

  • Inputs vs Arguments in Python

  • Built-In Functions in Python

  • Function Parameters in Python

  • Which of the following are true about functions in Python? (choose all that apply)

  • Lambdas in Python

  • Examples of Python Arithmetic Functions

  • Python Generator

    Concept icon
logo 1cademy1Cademy

Optimize Scalable Learning and Teaching

How it worksCoursesResearch CommunitiesBenefitsAbout Us
TermsPrivacyCookieGDPR

Contact Us

iman@honor.education

Follow Us




© 1Cademy 2026

We're committed to OpenSource on

Github