match..case statement in PYTHON The latest Python starting from Python 3.10, a match..case structure has been introduced as an alternative to switch..case in other languages. Syntax: match term : case pattern - 1 : action - 1 case pattern - 2 : action - 2 case pattern - 3 : action - 3 .... .... case pattern-n: action-n case _ : default-action statement - x If any pattern (pattern-1, pattern-2, pattern-3, ..., pattern-n) starting from pattern-1 is matched with the term, then the corresponding action will be performed, and after that, the statement following the match..case will execute. i.e., statement-x. If none of the patterns match, case ...
PYTHON - OFFICIAL WEBSITE, LATEST VERSION, REQUIREMENTS AND INSTALLATION www.python.org is the official website address for PYTHON Python 3.10.4 is the latest version and it was introduced on March 24th 2022 Python 3.9+ versions cannot be used with Windows 7 or earlier versions. INSTALLATION OF PYTHON 3.10.4
What is the output of the print(x) statements in the below example? >>>x = set(("apple","banana","cherry")) >>>print(x) >>>x.add("orange") # adds a single element >>>print(x) >>>x.update(["pine apple", "mango", "grapes"]) # iterates over the sequence and adds elements in the sequence >>>print(x) output {'cherry', 'banana', 'apple'} {'cherry', 'banana', 'orange', 'apple'} {'orange', 'apple', 'pine apple', 'banana', 'grapes', 'cherry', 'mango'} Why the elements are not printed in specific order???? ANS: set is an unordered collection of elements set is mutable, iterable set does not contain duplicate elements order of elements in a set is undefined
Comments
Post a Comment