Showing posts with label Example code for frozenset. Show all posts
Showing posts with label Example code for frozenset. Show all posts

Wednesday, November 18, 2020

, , ,

frozenset() function in python With Example Code - Python Function

  •  The frozenset() function in python is an inbuilt function is Python.
  • That Function takes an iterable object as input and makes them immutable. 
  • it freezes the iterable objects and makes them unchangeable.
  • frozen sets can be helpful in  Dictionary it can be used as key because it remain the same after creation.

Parameter for the  frozenset() function in Python

it use a single parameter iterable which can be ( dictionary, tuple, etc.)

Return value : - 

  • The frozenset() function in python returns an immutable frozenset.
  • it return the empty frozenset only if no parameters are passed to this function.

Example code for frozenset function in python :- 


# tuple of vowels
vowels = ('a', 'e', 'i', 'o', 'u')

fset = frozenset(vowels)
print('The frozen set is:', fset)
print('The empty frozen set is:', frozenset())

# frozensets are immutable
fSet.add('v')

OUTPUT

Example code for frozenset
Example code for frozenset