9 Magical facts about Python. Knowing facts is important | by Felix Antony | Nov, 2020

[ad_1]


Knowing facts is important

Felix Antony

Python is a general-purpose programming language. It is very easy to learn, easy syntax and readability are some of the reasons why developers are switching to python from other programming languages.

We can use python as object oriented and procedure oriented language as well. It is open source and has tons of libraries for various implementations.

Python is a high level interpreted language, which is best suited for writing python scripts for automation and code re-useability.

It was created in 1991 by Guido Van Rossum. The origin of its name is inspired by the comedy series called ‘Monty python’. Working with python gives us endless possibilities. We can use python in data science, machine learning, Artificial intelligence, web development, software development etc.

In order to work with any programming language, you must be familiar with an IDE. You can find the setup for an IDE for python, on ‘python.org’ and install ation is seemingly easy and comes with IDLE for writing python programs. After you have installed python on your system, you are all set to write programming language.

Photo by Clark Tibbs on Unsplash

Now I give 10 magical facts in the python language:

1. One can return multiple values in python Don’t believe see the below code snippet:

Output:

(1, 2, 3, 4, 5)

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.

Output:

3. In Python, everything is done by reference. it doesn’t support points.

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

Output:

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

Output:

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

Output:

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

Output:

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.

Output:

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,

Output:

Closing Thoughts:

Any fool can write code that a computer can understand. Good programmers write code that humans can understand. So keep learning, keep rocking. Thank you for reading this article. You can follow me on medium.

[ad_2]




Source link

Write a comment