P

@Puvi0707

List operation min 4.

SQL
4 years ago
a=[6,3,7,0,1,2,4,9] print(min(a))

List operation 3.max

SQL
4 years ago
a=[6,3,7,0,1,2,4,9] print(max(a))

Repetition list operation 2.

Python
4 years ago
a=["hello","world"]*2 print(a)

List operation 1.len concatenation

Python
4 years ago
len([1,2,3,4,5,6,7,8,9,10]) print([1,2,3,4,5]+[6,7,8,9,10])

Call each function in a list

Python
4 years ago
L=[lambda x: x *2,lambda x: x *3, lambda x: x *4] for f in L: print(f(5), end=" ") print("/n Multiplying the value of 100 by 2 we get : ",(L[0](100)))

Positive numbers

Python
4 years ago
def is_positive (x): if x>=0: return x num_list=[10, -20, 30, -40, 50, 68, 78, 80, -90, -100] list=[ ] list=list(filter(is_positive, num_list)) print("Positive Values list=",list)

Utility of tuple

Python
4 years ago
quo,rem=divmod(25,5) print(quo,rem)

List of 2 individual list

Python
4 years ago
list1=["hello","WELCOME" ,"TO", "the","world","of","PYTHON"] letters=[ ] for word in list1: letters.append(word[0]) print(letters)

Lower case

Python
4 years ago
def to_lower(str): return str.lower() list1=["HELLO", "WELCOME", "TO", "PYTHON"] list2=list(map(to_lower, list1)) print("List in lowercase characters is: ", list2)

Find largest value using reduce

Python
4 years ago
import functools num_list=(4,1, 8, 2,9,3,0) print("Largest value in the list is: ",functools.reduce(max,num_list))

Temperature prog

Python
4 years ago
def convert_to_F(Temp_C): return ((float(9)/5) *Temp_C + 32) Temp_in_C= (36.5, 37, 37.5,39) Temp_in_F =list (map(convert_to_F, Temp_in_C)) print("List of temperatures in Celsius : ", Temp_in_C) print("List of temperatures in Fahrenheit : ", Temp_

Fibonacci

Python
4 years ago
def recur_fibonacci(n): if(n<=1): return n else: return(fibonacci(n-1)+fibonacci(n-2)) n=int(input("enter a number of terms")) print("fibonacci sequence:") for i in range(n): print(fibonacci(i))

Matrix program

Python
4 years ago
X = [[2,5,4], [1,3,9],[7,6, 2]] Y = [[1,8,5],[7,3,6],[4,8,9]] result=[[0,0,0],[0,0,0],[0,0,0]] for i in range(len(X)): for j in range(len(X[0])): result[i][j] = X[i][j] + Y[i][j] for r in result: print (r)

Finding 2 points

Python
4 years ago
import math P1=[] P2=[] X1=int(input("Enter the x co-ordinate of starting point:")) Y1=int(input("Enter the y co-ordinate of starting point:")) X2=int(input("Enter the x co-ordinate of ending point:")) Y2=int(input("Enter the co-ordinate of ending

Finding 2 pts

Python
4 years ago
import math P1=[] P2=[] X1=int(input("Enter the x co-ordinate of starting point:")) Y1=int(input("Enter the y co-ordinate of starting point:")) x2=int(input("Enter the x co-ordinate of ending point:")) y2=int(input("Enter the co-ordinate of ending

Linear search

Python
4 years ago
n=int(input ("Enter the number of elements in the array: ")) i =0 l=[] for i in range(n): num=int(input()) l.append(num) print("Array is: ", l) val= int(input("Enter the number to be searched: ")) beg=0 end=n-1

Sum of elements of arrary

Python
4 years ago
import array as arr a= arr.array('i', [1,2,3,4,5]) Sum = 0 for i in a: Sum = sum + i print("Sum of elements", sum)

Implementing selection sort

Python
4 years ago
def selectionsort(A): for i in range(len(A)-1): pos = 1 for j in range(i+1, len(A)): if(A[pos] > A[j]) : pos= j A[i], A[pos] = A[pos], A[i] return (A) A = [5, 1, 6, 9, 2, 7, 3] A= selectionsort (

Binary search

Python
4 years ago
n=int(input ("Enter the number of elements in the array: ")) i =0 1=[] for i in range(n): Num=int(input()) append(num) print("Array is: ", 1) Val= int(input("Enter the number to be searched: ")) Beg=0 end=n-1

Sqrt of no

Python
4 years ago
X=float(input("Enter a number: ")) X_sqrt=X**0.5 print(" Square Root of %0.2f is %0.2f "%(X,X_sqrt))