"Enter Height" "Enter Base" "Area of Triangle": #Intersectionn List
"Enter Height" "Enter Base" "Area of Triangle": #Intersectionn List
In [7]: list1=[12,15,55,95,46,82,74,52]
list2=[65,45,2,85,78,32,48]
list3=sorted(list1+list2)
print(list3)
[2, 12, 15, 32, 45, 46, 48, 52, 55, 65, 74, 78, 82, 85, 95]
In [8]: list2=[65,45,2,85,78,32,48]
list2.append(100)
print(list2)
In [12]: list2=[65,45,2,85,78,32,48]
list2.remove(2)
print(list2)
In [13]: list2=[65,45,2,85,78,32,48]
list2.reverse()
print(list2)
In [19]: list1=[2, 12, 15, 32, 45, 46, 55, 55, 55, 65, 74, 78, 82, 82, 95]
list2=set(list1)
print(list2)
{32, 65, 2, 74, 12, 45, 46, 15, 78, 82, 55, 95}
In [26]: list1=[12,15,55,95,46,82,74,52]
list2=[12,45,52,85,78,32,46]
list3=set(list1)|set(list2)
print(list(list3))
[32, 74, 12, 45, 46, 15, 78, 82, 52, 85, 55, 95]
print(list3)
In [32]: a=["apple","banana","grapes","kiwi","apple","watermelon"]
b=input("Enter the element you want to remove ")
c=[]
file:///C:/Users/ASUS/Downloads/Untitled2.html 1/3
5/31/24, 10:09 AM Untitled2
In [38]: a="The cat sat on the mat and then the cat jumped off the mat"
word=a.split(" ")
b=input("Enter the word you want to find")
print(word)
count=0
for i in word:
if(i==b):
count = count +1
if(count == 0):
print("entered word is not found")
else:
print("Occurence of the word",b,"is",count,"times")
['The', 'cat', 'sat', 'on', 'the', 'mat', 'and', 'then', 'the', 'cat', 'jumped',
'off', 'the', 'mat']
Occurence of the word cat is 2 times
In [39]: a="The cat sat on the mat and then the cat jumped off the mat"
sub_str="The cat sat"
if sub_str in a:
print("Sub string is present")
else:
print("substring is not present")
In [41]: name=["Raj","ketan","Ruturaj"]
marks=[95,85,98]
mapped_dict= dict(zip(name,marks))
print(mapped_dict)
In [44]: b="The cat sat on the mat and then the cat jumped off the mat"
a={}
word=b.split(" ")
for i in word:
if i in a:
a[i]+=1
else:
a[i]=1
print(a)
file:///C:/Users/ASUS/Downloads/Untitled2.html 2/3
5/31/24, 10:09 AM Untitled2
In [ ]:
file:///C:/Users/ASUS/Downloads/Untitled2.html 3/3