Saturday, 14 October 2017

9 Interesting facts about Python Programming language

1.There is actually a poem written by Tim Peters named as THE ZEN OF PYTHON which can be read by just writing "import this" in the interpreter.


2.One can use an “else” clause with a “for” loop in Python. It’s a special type of syntax that executes only if the for loop exits naturally, without any break statements.



3.In Python, everything is done by reference. It doesn’t support pointers.

4.Function Argument Unpacking is another awesome feature of Python. One can unpack a list or a dictionary as function arguments using * and ** respectively. This is commonly known as the Splat operator. Example here



5.Want to find the index inside a for loop? Wrap an iterable with ‘enumerate’ and it will yield the item along with its index. See this code snippet



6.One can chain comparison operators in Python answer= 1<x<10 is executable in Python. More examples here



7.We can’t define Infinities right? But wait! Not for Python. See this amazing example


8.Instead of building a list with a loop, one can build it more concisely with a list comprehension. See this code for more understanding.

9. Finally, Python’s special Slice Operator. It is a way to get items from lists, as well as change them. See this code snippet



No comments:

Post a Comment