Example
Output
{'apple','banana','guava'}
sets
Output
<class 'set'>
3
3
| Function | Example | output |
|---|---|---|
| len | len(var) | 4 |
| type | type(var) | <class 'set'> |
| add | var.add("what's up") | {'hi','hallo','who','what','what's up'} |
| update | var.update(var1) | {'hi','hallo','who','what',1,2,3} |
| remove | var.remove('hi') | {'hallo','who','what'} |
| discard | var.remove('hi') | {'hallo','who','what'} |
| pop | var.pop('hi') | {'hallo','who','what'} |
| clear | var.clear() | {} |
| del | del var | |
| union | var.union(var1) | {'hi','hallo','who','what',1,2,3} |
| intersection_update | var.intersection_update(var2) | {'hi'} |
| intersection | var.intersection_update(var2) | {'hi'} |
| symmetric_difference_update | var.symmetric_difference_update(var2) | {'hallo','who','what','when','why'} |
| symmetric_difference | var.symmetric_difference_update(var2) | {'hallo','who','what','when','why'} |
| copy | x = var.copy() | {'hi','hallo','who','what'} |
| isdisjoint | var.isdisjoint(var1) | True |
Python arrays
- Tuple:tuple is written in Parentheses (), collection of immutable and ordered values. allow duplicate.
- List:list is written in square brackets [], collection of mutavle and ordered values. allow duplicate.
- Dict:Dict is written in curly brackets {}, collection of unordered and mutable values. not allow duplicate.
- Set:sets is written in curly brackets {}, collection of unordered , unindexed and immutable values. not allow duplicate.
No comments:
Post a Comment
Tell us how you like it.