The Beauty of Python — functions

In modern era, the mindset is in the direction that we want to get everything with maximum efficiency and less efforts.With respect to programming, python is here to nearly fulfill the conditions. And hence python is future of programming languages. The reason behind its beauty is the features it has. One by one let’s unfold the story of python. Let’s begin with functions.

E.g. addition of two data — the data may be integer, float, string or list

Here, the beauty of language is no need to write three different functions for addition of integer, float and string resp. The single additionOfAnything() is enough irrespective of data types.

A. integer — additionOfAnything(12,9)

B. float additionOfAnything(12.3,4.7)

C. string — additionOfAnything(‘hello ’,’world!’) i.e. nothing but strings concatenation

D. list — C. string — additionOfAnything(l1st1,list2) i.e. nothing but lists concatenation

In general, the definition of function is ‘a program that performs a specific task’ but here in python — function is defined as ‘a program that performs a specific task irrespective of data type’. The above examples show, the data type of result is same as that the inputs and that’s the beauty of the language.

Like what you read? Give hat _knot a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.