Data ScienceLesson 7Free preview
DS Functions
This lesson is part of Data Science · All levels
Summary
A function is a block of code named that can be called repeatedly to perform a particular task. In Python, a function is defined by the def keyword, receives parameters as input, and can return values via return. Embedding logic into a function makes code more concise, easier to test, and less repetitive.
Key points
- Definition of a function:...
- The parameter carries input values; the argument is the value when called.
- Returns the value to the caller; prints only display to the screen.
- The function reduces code duplication (DRY) and facilitates testing.
- Built-in functions such as len(), sum(), and range() are ready to use.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.