Python‎ > ‎set‎ > ‎

set.copy()

http://www.adilwaseem.com/

Introduction
Return a shallow copy of a set.

Syntax
set.copy(x)

Parameters
x=set items

Example
The method copy the set1.
 set1={3,45,344,66}
set2=set1.copy()
print(set2)

>>> 
{344, 66, 3, 45}
>>> 

The method return the set1 string items.
 >>> set1={"Python", "Research", "Centre"}
>>> set1.copy()
{'Centre', 'Python', 'Research'}
>>>



from decimal import Decimal

set1={Decimal(0.1).to_integral_value(),Decimal(1.9).to_integral_exact(),Decimal(1.5000001).to_integral(), Decimal(10).shift(2)}

print(set1.copy())

>>>
{Decimal('1000'), Decimal('0'), Decimal('2')}
>>>


set.copy()
The method return the copy of Decimal items of set(a)
 >>> from decimal import Decimal
>>> a=set()
>>> a.add(Decimal(1).adjusted())
>>> a.add(Decimal(.55).canonical())
>>> a.add(Decimal(-1).compare_signal(1))
>>> a
{0, Decimal('0.5500000000000000444089209850062616169452667236328125'), Decimal('-1')}
>>> b=set()
>>> b.add(Decimal(1).compare_total(2))
>>> b.add(Decimal(0.1).copy_abs())
>>> b
{Decimal('0.1000000000000000055511151231257827021181583404541015625'), Decimal('-1')}

>>> a={0, Decimal('0.5500000000000000444089209850062616169452667236328125'), Decimal('-1')}
>>> a.copy()
{Decimal('0.5500000000000000444089209850062616169452667236328125'), 0, Decimal('-1')}

Comments