.union() The .union() operator returns the union of a set and the set of elements in an iterable. Sometimes, the | operator is used in place of .union() operator, but it operates only on the set of elements in set . Set is immutable to the .union() operation (or | operation). Example >>> s = set("Hacker") >>> print s.union("Rank") set(['a', 'R', 'c', 'r', 'e', 'H', 'k', 'n']) >>> print s.union(set(['R', 'a', 'n', 'k'])) set(['a', 'R', 'c', 'r', 'e', 'H', 'k', 'n']) >>> print s.union(['R', 'a', 'n', 'k']) set(['a', 'R', 'c', 'r', 'e', 'H', 'k', 'n']) >>> print s.union(enumerate(['R', 'a', 'n', 'k'])) set(['a', ...
Popular posts from this blog
XAMPP, SQL BASIC COMMANDS
Microsoft Windows [Version 10.0.19042.867] (c) 2020 Microsoft Corporation. All rights reserved. C:\Users\darul Haram>../.. '..' is not recognized as an internal or external command, operable program or batch file. C:\Users\darul Haram>cd../.. C:\>xampp 'xampp' is not recognized as an internal or external command, operable program or batch file. C:\>cd xampp C:\xampp>cd mysql C:\xampp\mysql>cd bin C:\xampp\mysql\bin>../ '..' is not recognized as an internal or external command, operable program or batch file. C:\xampp\mysql\bin>cd .// C:\xampp\mysql\bin>cd ../ C:\xampp\mysql> -u root -p -h localhost '-u' is not recognized as an internal or external command, operable program or batch file. C:\xampp\mysql>cd bin C:\xampp\mysql\bin>cd mysql The system cannot find the path specified. C:\xampp\mysql\bin>mysql -u root -p -h localhost Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB ...
Sets
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information. >>> ##Almost similar to sets in maths >>> a={1,2,3,4,5} >>> type(a) <class 'set'> >>> ## remember this below >>> a={} >>> type(a) <class 'dict'> >>> ##set >>> a=() >>> type(a) <class 'tuple'> >>> ##above fo tuple >>> ##below for set >>> a=set() >>> type(a) <class 'set'> >>> ##sets are immutable >>> ##sets doesnt have any index , no order >>> a={10,90,100,3,5,40,70} >>> set(a) {3, 100, 5, 70, 90, 40, 10} >>> set(a) {3, 100, 5, 70, 90, 40, 10} >>> set(a) {3, 100, 5, 70, 90, 40, 10} >>> set[0] set[0] >>> a[0] Traceback (most recent call last):...
Comments
Post a Comment