Posts

Showing posts from April, 2021

Lambda Function (PYTHON)

# SYNTAX. # lambda arguments : expression # Addition using LAMBDA function. x = lambda a : a + 10 print (x( 5 )) #The expression is executed and output is returned. # Subtraction using Lambda function y= lambda b:b- 20 print (y( 30 )) # Multiplication using LAMBDA function. x = lambda a : a * 10 print (x( 4 )) # Division using LAMBDA function. x = lambda a : a / 10 print (x( 5 )) # More than one argument. x = lambda a , b , c : a + b + c print (x( 5 , 6 , 2 )) # Lambda function with another function. # Function that doubles the value. def myfunc (n):   return lambda a : a * n mydoubler = myfunc( 2 ) print (mydoubler( 11 )) #   Similarly we can change the values passed and get different results.     #python #programming #coding #programmer #snake #machinelearning #code #coder #ballpython #pythonprogramming #computerscience #datascience #reptile #snakes #reptiles #snakesofinstagram #reptilesofinstagram #technology #pythonsofinstagram #artificialintelli

MATRIX BASIC PROGRAMS (PYTHON)

  # MATRIX input. row = int ( input ( "Enter the number of rows:" )) column = int ( input ( "Enter the number of columns:" )) # Addition of two MATRICES. X=[[ 1 , 2 , 3 ] , [ 3 , 4 , 5 ] , [ 6 , 7 , 8 ]] Y=[[ 3 , 4 , 5 ] , [ 6 , 4 , 5 ] , [ 5 , 9 , 8 ]] Z=[[ 0 , 0 , 0 ] , [ 0 , 0 , 0 ] , [ 0 , 0 , 0 ]] for i in range ( len (X)): #len[X] is length of rows i.e no of small brackets. for j in range ( len (X[ 0 ])): #X[0] gives idea of number of columns. Z[i][j]=X[i][j]+Y[i][j] for r in Z: print (r) # Subtraction of two MATRICES. X=[[ 2 , 3 , 4 ] , [ 4 , 5 , 6 ] , [ 7 , 6 , 7 ]] Y=[[ 3 , 4 , 5 ] , [ 6 , 7 , 8 ] , [ 2 , 1 , 3 ]] Z=[[ 0 , 0 , 0 ] , [ 0 , 0 , 0 ] , [ 0 , 0 , 0 ]] for i in range ( len (X)): for j in range ( len (X[ 0 ])): Z[i][j] = X[i][j] - Y[i][j] for r in Z: print (r) # Multiplication of two MATRICES. X=[[ 1 , 2 , 3 ] , [ 3 , 4 , 5 ] , [ 6 , 7 , 8 ]] Y=[[ 3 , 4 , 5 ] , [ 6 , 4 , 5

PYTHON BASIC PROGRAMS

#1.Hello world program. print ( "Hello World" )   #2.Addition of two numbers. a= int ( input ( "Enter the   first number" )) b= int ( input ( "Enter the second number" )) print (a+b)   #3.To find the square root &$ check the program. a= float ( input ( "enter the number" ) # b= a ** 0.5 print (b)   #4.To find area of triangle. a= float ( input ( "enter the base of triangle" )) b= float ( input ( "enter the height of triangle" )) c=( 1 / 2 )*a*b print ( "The area of triangle is" , c) OR a= float ( input ( "enter the base side of triangle" )) b= float ( input ( "enter the 2nd side of triangle" )) c= float ( input ( "enter the 3rd side of triangle" )) d=(a+b+c)/ 2 area=(d*(d-a)*(d-b)*(d-c))** 0.5 print (area)   #5.Swapping 2 variables. a= int ( input ( "enter the number1" )) b=( int ( input ( "enter the second

Popular posts from this blog

PIR SENSOR (PASSIVE INFRARED SENSOR)