Posts

Showing posts from May, 2020

Lambda function or anonymous function

Image
Lambda function or anonymous function What is lambda  function? Lambda function is a function they are not declared as other function using def keyword.Rather they are created using lambda keyword. Syntax: lambda argument:Expression Example: sum = lambda   x , y  :x+y print ( sum ( 7 , 5 )) #in the above code lambda function return the value of sum. #in lambda function x,y:x+y (x,y is agreement and x+y is expression that  #get evaluate and return) #it return function object which assign to the identifier sum. lambda function have no name. lambda function can take any number of argument. They are one line argument and hence can not contain multiple line. lambda function can not even access global variable. lambda function with ordinary function def   increment ( y ):       return ( lambda   x :x+ 1 )(y) # in ordinary function return lambda function. #in lambda function x is argument,x+1 is expression #and y is assign argument/passing

What is function?What is function in python?

Image
Function in python What is function? What is function in python? Function is the most important tool in procedural programming language.A function can be defined as it is a block of statement which is used to perform any particular operation according to requirement.A function is a  block of organized and reusable program and code that perform a specific and as well as definite task.The main objective to create a function is to reduce the complexity of a program, in this case a program can be divided in to multiple parts according to requirement that part is called function or module. We can create user friendly program with the help of function in this case user can create separate function for each module  module according to requirement. It provide extensibility , it means program can be enhanced module wise in feature. it also provide reusable of program, it means a function can coll more than one times There are two types of function one predefined function like-di

python pattern programming

Image
PYTHON PATTERN PROGRAMMING Python nested loop: Python allow programmer to use nested loops.Nested loop means when one loop is define into another loop is known as nested loop,in which one is called inner loop and another is called outer loop.In which when outer loop's condition is true than inner loop will be execute. we use the concept of nested loop in pattern programming etc. syntax: while (condition):      while (condition):         statement x     statement y   Some examples of nested loop. Nested loop program. Q. write  a program to print following pattern. P P Y P Y T P Y T H P Y T H O P Y T H O N str = "PYTHON" for  i  in   range ( 0 , 6 ):      print ()      for  j  in   range ( 0 ,i+ 1 ):          print (str[j],  end = ' ' ) Q. write  a program to print following pattern. *  * *  * * *  * * * *  * * * * * for  i  in   range ( 1 , 6 ):          print ()          for