From the course: Python for Health Sciences and Healthcare

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Functions

Functions

- [Instructor] In this chapter, we're going to cover, common Python functions and statements. One of the interesting things about programming is reusability. Functions are an integral path of being able to reuse code in other programs. A function is the named block of code, that performs the specific action. To paint the vivid picture, we want to add two numbers, for the volume of lab reagents. Simply type 100 plus 100, or 200 plus 100 This isn't a big deal, if we need to do this like five times or maybe 10 times. But what if we need to do these a 100, or a 1000 or a million times? This is where functions shine. Rather than repeat ourselves, let's simply write the function called addition, to do this for us. In Python, def is the expression to define a function, and it's reserved for just that. So, def addition is a function name. A function is designed to add two values per time. So, we have value one and value…

Contents