In this lesson, I am going to teach you how to use the function in Python.
Functions are smaller reusable code blocks. It is like a container which contains the code to perform a specific task. Actually, we have been using functions since the beginning of this course. For example – print function, input function and so on. Each of these functions has a purpose. For a small program, we can get things done without functions. But, when we build large complex programs, we need to break our code into smaller reusable functions. And that's what I am going to show you in this lesson.
The Python code used in this lesson:
def total_cost(price, shipping, discount):
print(f"Total cost: ${price + shipping - discount}")
total_cost(shipping=5, discount=1, price=10)
def welcome(fist_name, last_name):
print(f"Hi {fist_name} {last_name}")
welcome("Nuruzzaman", "Faruqui")
‘You are free to copy, edit, use and distribute this code without crediting the author. Enjoy copyright-free content.’ – Nuruzzaman Faruqui.
On this page of the site you can watch the video online Function in Python with a duration of hours minute second in good quality, which was uploaded by the user Nuruzzaman Faruqui 23 September 2021, share the link with friends and acquaintances, this video has already been watched 549 times on youtube and it was liked by 8 viewers. Enjoy your viewing!