Important Notice:

Course Content
Set Data Type in Python (Chapter-14) M3-R5
About Lesson

Set Functions in Python

Set Function

Description

all()

sequence के सभी elements True होते है तो ये तो ये True return करता है।

any()

sequence का एक या सभी elements True होते है तो ये तो ये True return करता है।

len()

set की length को return करता है।

max()

set से max value को return करता है।

min()

set से min value को return करता है।

set()

अलग ढंग से set को create या sequence को set में convert करता है।

sorted()

दिए गए sequence को sort करके return करता है।

sum()

दिए गए sequence या collection के elements को add करके उनका sum return करता है

 

 

1.       s1={10,15.02,’ak it solution’}

print(all(s1))                                                                                            # True

 

  1. s1={10,15.02,’ak it solution’,False}

print(any(s1))                                                                                            # True

 

  1. s1={10,15.02,’ak it solution’}

print(len(s1))                                                                                             # 3

 

  1. s1={10,50,60,40,20,30}

print(max(s1))                                                                                           # 60

 

  1. s1={10,50,60,40,20,30}

print(min(s1))                                                                                            # 10

 

  1. s1=(10,50,60,40,20,30)

print(set(s1))                                                          # {40, 10, 50, 20, 60, 30}

 

  1. s1={10,50,60,40,20,30}

print(sorted(s1))                                                                  # [10, 20, 30, 40, 50, 60]

 

  1. s1={10,50,60}

print(sum(s1))                                                                                           # 120

 

 

Set Functions in Python

Set Function

Description

all()

If all the elements of the sequence are True then it returns True.

any()

If one or all elements of the sequence are True then it returns True.

len()

Returns the length of the set.

max()

Returns the max value from the set.

min()

Returns the min value from the set.

set()

Creates a set or converts a sequence into a set in a different way.

sorted()

Sorts and returns the given sequence.

sum()

Adds the elements of a given sequence or collection and returns their sum.

error: Content is protected !!