#32 Python Tutorial for Beginners | Functions in Python

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO20 (20% Discount)

Udemy Courses:

For More Queries WhatsApp or Call on : +919008963671

In this lecture we are discussing:
#1 What are functions?
#2 Arguments in function
#3 return statement in python

#1
-- A function is a block of code that performs a specific task.
-- Functions are used to break down larger programs into smaller and more manageable chunks,
making it easier to read, test, and debug code.
-- Functions can take input arguments, perform operations on them, and return output values.
-- To define a function in Python, you use the def keyword followed by the function name,
input parameters (if any), and a colon. The function body is then indented and contains the code to be executed.

# Here's an example of a simple Python function that takes two arguments and returns their sum:
def add_numbers(a, b):
sum = a + b
return sum

add_numbers(4,5) # calling the function
# without calling the function cannot run

#2
Arguments in python
-- whatever variable is used inside a function during the defining of the function is called a formal argument.
-- whatever value you passed during the calling is called actual arguments.

#3
-- The return statement is used to exit a function and return a value.
-- The return statement can be used to return a value from a function.
-- The return statement can also be used to exit a function without returning a value.
-- If the return statement is without any expression, then the special value None is returned.
-- Functions without a return statement return None as their result.
def add_sub(x,y):
c = x+y
d = x-y
return c,d

result1,result2 = add_sub(4,5)
print(result1,result2)

# The above code defines a Python function called add_sub that takes two input arguments x and y. The function first adds x and y and stores the result in a variable called c. It then subtracts y from x and stores the result in a variable called d. Finally, it returns both c and d as a tuple.

# The function can be called with two arguments, as shown in the line result1,result2 = add_sub(4,5). This line assigns the values returned by the add_sub function to the variables result1 and result2, respectively. The print statement then outputs the values of result1 and result2 to the console.

More Learning :

Donation:
PayPal Id : navinreddy20
Рекомендации по теме
Комментарии
Автор

I’ve learned more from his videos than two years of paid college classes.

chriscruz
Автор

I could not understand what my teacher taught in 3 months, I am understanding in 10 minutes!
Thank you very much sir, may God bless you!👍

Steve-wory
Автор

Hello Sir, I never thought my brain would ever understand python this easy, thanks to you, wishing you health and happiness to you!!, also proud that I can add this to my skills as I have not learnt in my UG classes.

surampudiswetha
Автор

Always coming back here after paid online lectures

ademolaodusanya
Автор

7:34 the best explanation I have ever heard to understand types of function

Mamurjon
Автор

you explained very well which simply means that I learning programming and your words are making me more fluent with English.THANKS YOU SO MUCH

Mahi_
Автор

English is not even this guys first language yet he can still teach better than my high school Comp Sci teacher. Thank you for the tutorials!

arju
Автор

You are a phenomenal in explaining python concepts very well :)
Nice to have a good tutor like you

mdkhader
Автор

After finishing python tutorials it will not be the end, I will go through all of your tutorials this quarantine and make myself better... Thank you so much sir ❤️❤️

meenakshidas
Автор

Sir, you are doing exceptionally good work for us who are beginners in this field.
Your videos are really easily understandable .

vidyasadansteptowardsenlig
Автор

Sir I m telling you that your teaching skills is different from other it make me very easy to understand. Thanks a lot.

WorldUpdatesU
Автор

Very neat & clear explaination about Python functions Sir.
Thank you.

preethiyr
Автор

Thank you for making the material so digestible, even for those of us who hate programming!!

mohammadkhanafer
Автор

You are great sir
You just made my first project within a min
Print(“love you sir”)
Love you sir, here it is

surajkiran
Автор

I ve been trying to understand what return does for a while now nobody was able to explain it in such a way i would get it, you sir just did it! Thank you a thousand times! Like and sub!

gandalffury
Автор

These videos r amazingly helpful and clearly express the topic. Really like em👍👍

subhayansinha
Автор

Hi Naveen, Your videos are very good and really helping to get confidence. I am working on corporate having 13 years of experience and worked only in infra structure side. So, not having experience of Coding. But want to switch to programming as well. thanks for help

kisanmanila
Автор

Finally, someone who can explain this clearly.

hbs
Автор

Thank you so much navin sir.... Its fun to learn python... Ur videos makes codings interesting... 😍👌

deepshikasingh
Автор

That's a great work done by you sir it's helping every one a lot for learning quickly python thank you so much sir 🙏🏻🙏🏻 it's also like a rivision for me because I learned python earlier but it's not that clear in my mind like you did now all the concepts and basics I learnt to see your great and very interesting videos thank you so much sir for making videos like this 🙏🏻🙏🏻😊

arihantratdiya