0

Using Def

Can anyone tell me how to use def function in Python??

6th Oct 2025, 9:44 AM
Saksham Guragain
Saksham Guragain - avatar
2 Respostas
+ 3
Saksham Guragain , > functions in python and their use are described in the last module (`functions`) of the course `introduction to python`. > since you allready have started learning from this tutorial, just continue until you have finished it.
6th Oct 2025, 10:29 AM
Lothar
Lothar - avatar
+ 2
Hi! Once you've written a solution (as in the example of calculating the body mass index) and wrapped the calculation code in a function, you can call that function with a single line, simply passing in new values. Code written as a function is convenient to use in a large program in different parts of it, which simplifies the program itself and reduces the number of lines of code. For example, think about the console output function /print()/. You don't need to write it every time in your program to output something to the console. You simply call this function by its name, and everything else happens "under the hood." This code functionality was once written by a programmer and saved as a function, and it is also integrated into the Python programming environment. Please, check out my example: https://sololearn.com/compiler-playground/cm8ZPU450nAE/?ref=app https://sololearn.com/compiler-playground/cPP9jwAvj7Mr/?ref=app
6th Oct 2025, 10:28 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar