Python: Shallow copy of sets
Python sets: Exercise-11 with Solution
Write a Python program to create a shallow copy of sets.
Note : Shallow copy is a bit-wise copy of an object. A new object is created that has an exact copy of the values in the original object.
setp = set(["Red", "Green"]) setq = set(["Green", "Red"]) #A shallow copy setr = setp.copy() print(setr)
Visualize Python code execution:
The following tool visualize what the computer is doing step-by-step as it executes the said program:
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Python skills with w3resource's quiz
Python: Tips of the Day
i = 5 while i > 1: print("Whil-ing away!") i -= 1 if i == 3: break else: print("Finished up!")
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework