Every thing about Python3 functions


In this tutorial we will be learing about Fun Fun functions, thanks for reading our page, I will soon star to upload videos.
Let's go straight to the point. Functions are really fun in python, their main objective is too help you reduce your codes instead of writing them again and again. You write it once, the most important use is in recursive functions, I will post that later.
For example:
You want to loop through different file different times but still perform the same action on each elements of all files, you will find functions really helpful.
We have different types of functions in python which we will be talking about today

Code.     Download
total = 4
#Required arguments
def req(n):
 total = n ** 2
 print(total)
#Keyword arguments
def key(str,num):
 total = str * num
 print(total)



#Default arguments
def dlt(name,age="i") the:
 print(name, age)
#Variable-length arguments
def var(arg, *var_tuple):
 print(arg)
 for i in var_tuple:
  print(i)
#Anonymous arguments
sum = lambda n:n**2
req(4)
key(num = 3,str = "Ayo")
dlt("me",45)
var(3,4,5,6,7,8)
print(sum(6))

Post a Comment

0 Comments