5 967
Подписчики
Нет данных24 часа
-357 дней
-22530 дней
Архив постов
5 967
ISDISJOINT METHOD IN SET
x = {"Code", "With", "Rushi"}
y = {"Learn", "Coding", "Easily"}
z = x.isdisjoint(y)
print(z)
Output:
Truw5 967
INTERSECTION_UPDATE METHOD IN SET
x = {"Code", "With", "Rushi"}
y = {"Learn", "Code", "Easily"}
x.intersection_update(y)
print(x)
Output:
{'Code'}5 967
INTERSECTION METHOD IN SET
x = {"Code", "With", "Rushi"}
y = {"Learn", "Code", "Rushi"}
z = x.intersection(y)
print(z)
Output:
{'Code', 'Shani'}5 967
DISCARD METHOD IN SET
data = {"Code", "With", "Rushi"}
data.discard("Rushi")
print(data)
Output:
{'With', 'Code'}5 967
DIFFERENCE_UPDATE METHOD IN SET
x = {"Code", "With", "Rushi"}
y = {"Learn", "Coding", "Easily"}
x.difference_update(y)
print(x)
Output:
{'Code', 'Rushi', 'With'}5 967
DIFFERENCE METHOD IN SET :
x = {"Code", "With", "Rushi"}
y = {"Learn", "Coding", "Easily"}
z = x.difference(y)
print(z)
Output:
{'Code', 'Rushi', 'With'}5 967
COPY METHOD IN PYTHON :
data = {"Code", "With", "Rushi"}
x=data.copy()
print(x)
Output:
{'With', 'Rushi', 'Code'}5 967
CLEAR METHOD IN SET :
data = {"Code", "With", "Rushi"}
data.clear()
print(data)
Output:
set()5 967
ADD METHOD IN SET :
data = {"Code", "With", "Rushi"}
data.add("Programmer")
print(data)
Output:
{'Code', 'With', 'Programmer', 'Rushi'}5 967
EXAMPLE 2 : GETTING DATA FROM SET USING FOR LOOP
data = {1, 2, 3, 4, 5, 5, 6, 6, 7, 9, 10}
for i in data:
print(i)
Output:
1
2
3
4
5
6
7
9
10
#Ignores Duplicate Value5 967
EXAMPLE 1 : CREATING A SET
data = {1, 2, 3, 4}
print(data)
Output:
{1, 2, 3, 4}5 967
WHAT IS SET ?
A Set is an unordered collection data type that is iterable, mutable, and has no duplicate elements.
Sets are used to store multiple items in a single variable.
Set is one of 4 built-in data types in Python used to store collections of data, the other 3 are List, Tuple, and Dictionary, all with different qualities and usage.
A set is a collection which is unordered, unchangeable*, and unindexed.
Note : Set items are unchangeable, but you can remove items and add new items.
Set are represented by { } (values enclosed in curly bracets)
5 967
TUPLE INDEX() METHOD
thistuple = (1, 5, 8, 2, 5, 4, 5, 8)
x = thistuple.index(8)
print(x)
Output:
25 967
TUPLE COUNT() METHOD
thistuple = (1, 5, 8, 2, 5, 4, 5, 8)
x = thistuple.count(5)
print(x)
Output:
35 967
EXAMPLE 11 : CONCATENATION OF TWO TUPLE
data1 = ("Rushi" , "Lade" , 16)
data2 = ("Code" , "With", "Rushi", ".com")
print(data1 + data2)
Output:
('Rushi', 'Lade', 16, 'Code', 'With', 'Rushi', '.com')5 967
EXAMPLE 10 : PYTHON MIN & MAX FUNCTION
print('Maximum is : ', max(1, 3, 2, 5, 4))
print('Minimum is : ', min(1, 3, 2, 5, 4))
Output:
Maximum is: 5
Minimum is: 15 967
EXAMPLE 9:
data = ( 1 , "Rushi" , 8.0 , ["Rushi" , "Lade" , 29] , "RL")
data[3].pop()
data[3].append("Code")
data[3].remove("Lade")
print(data)
Output:
(1, 'Rushi', 8.0, ['Rushi', 'Code'], 'RL')