# Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, Testing, CI Tutorials in Easy Languages.

## List Special Operation  in Python

We can perform concatenation using + operator, multiplication, or repetition using *  and spiting element of the list using [:] .which has been described by the following example.

a=[1,2,3,7,8,1]
del(a)
b=[4,5,6]
c=a+b
print(c)
c=a*3
print(c)

print(a[1:3])
print(a[1:])
print(a[:3])
print(a[-3:-1])

Assignment of List:-

Check if a key is present in every segment of size k in an array

Find the minimum and maximum element in an array

Write a program to reverse the array

Write a program to sort the given array

Find the Kth largest and Kth smallest number in an array

Find the occurrence of an integer in the array

Sort the array of 0s, 1s, and 2s

Range and Coefficient of array

Move all the negative elements to one side of the array

Find the Union and Intersection of the two sorted arrays

Level 2
Write a program to cyclically rotate an array by one

Find the missing integer

Count Pairs with given sum

Find duplicates in an array

Sort an Array using the Quicksort algorithm

Find common elements in three sorted arrays

Find the first repeating element in an array of integers

Find the first non-repeating element in a given array of integers

Find the largest three elements in an array Time

Rearrange the array in alternating positive and negative items

Find if there is any subarray with sum equal to zero

Find Largest sum contiguous Subarray

Find the factorial of a large number

Find Maximum Product Subarray

Find longest consecutive subsequence

Find the minimum element in a rotated and sorted array

Find all elements that appear more than N/K times

GCD of given index ranges in an array

Minimize the maximum difference between the heights

Minimum number of jumps to reach the end

Find the two repetitive elements in a given array

Find a triplet that sums to a given value

Construct a N*M matrix from the user input

Find the row with the maximum number of 1’s

Print the matrix in a Spiral manner

Find whether an array is a subset of another array

Implement two Stacks in an array

Majority Element

Wave Array

Trapping Rainwater

Level 3
Maximum Index

Max sum path in two arrays

Find Missing And Repeating

Stock buy and sell Problem

Pair with given sum in a sorted array

Chocolate Distribution Problem

Longest Consecutive Subsequence

Print all possible combinations of r elements in a given array

POST Answer of Questions and ASK to Doubt

1. WAP to count total even number and Odd number in Tuple?
Sol:-t=(1,2,3,4,5,6,7,8,9)
count1=0
count2=0
for i in t:
if i%2==0:
count1=count1+1
else:
count2=count2+1
print("count of even numbers:",count1)
print("count of odd numbers:",count2)

2. #Wap to find Negative Elements in list?

lst=[-2,4,2,-8,5,-4,55,44,-7]
for i in range(0,len(lst)):
for j in range(i,len(lst)):
if lst[i]==lst[i] and lst[i]<0:
print("Negative Elements",lst[j])
break

3. #Wap Program to reverse the list?
lst=[3,4,2,5,65]
for i in range(len(lst)-1,-1,-1):
print(lst[i],end=' ')

4. #WAP to Find max and min Element in list?
lst=[44,22,11,55,44]
maxi=lst
for i in range(0,len(lst)):
if maxilst[i]:
minn=lst[i]
print("Minimum Element is ",minn)

5. #WAP to Sort the list using sort() method ?
lst=[6,4,7,8,2]
lst.sort()
print(lst)

6. This comment has been removed by the author.

7. #Find whether an List is a subset of another List?

lst=[10,4,5,7,2]
lst1=[2,7,4]
for i in lst:
if i in lst1:
print("List1 is Subset of List",lst,lst1)
break

8. #sorting a ist
x=[12,25,85,32,14]
for i in range (0,len(x)):
for j in range(i+1,len(x)):
if x[i]>x[j]:
x[i],x[j]=x[j],x[i]
print(x)
#sorting decreasing order:
x=[12,25,85,32,14]
for i in range (0,len(x)):
for j in range(i+1,len(x)):
if x[i]<x[j]:
x[i],x[j]=x[j],x[i]
print(x)

9. #duplicate element remove
def Remove(duplicate):
final_list=[]
for num in duplicate:
if num not in final_list:
final_list.append(num)
return final_list
duplicate=[2,4,10,20,5,10,8]
print(Remove(duplicate))

#another mathod
l=[2,4,10,20,5,10,8]
a=list(set(l))
print(a)

10. #find out negative element in the list
list=[-1,2,5,-3,55,-26,27]
for i in range (0,len(list)):
for j in range(i,len(list)):
if list[i]==list[j]and list[i]<0:
print("negative element",list[j])
break

11. #subset of list
l1=[1,2,4,5,8]
l2=[2,5,9,6,4,10,12,25]
for i in l1:
if i in l2:
print("l2 is subset of l1",l1,l2)
break

12. #counting even or odd element in tuple
t=(1,2,3,4,5,7,8,9,)
count1=0
count2=0
for i in t:
if i%2==0:
count1=count1+1
else:
count2=count2+1
print("count of even number",count1)
print("count of even number", count2)

13. #square of list element
x = [4, 5, 6, 7, 11, 12]
y = [i ** 2 for i in x]
print(y)

# 2nd method
def square(list):
ret = []
for i in list:
ret.append(i ** 2)
return ret
# 3rd method:
def square(list):
for i in list:
yield i**2