Python is a popular programming language. Thousands of websites of companies are building in python language, which includes: Dropbox, Google, Facebook, Instagram and Reddit. Python is used to perform for all kinds of things, such as website creation, web scraping, natural language processing, data analysis and machine learning. The language is designed to be easy, but at the same time, it is very powerful, which excite the beginner programmers to learn python language.
Why do companies prefer Python?
Initially, python 1.0 is launched then python 2.0 and Python 3.0 introduced in 2008 now with the added features, companies are using Python 3.5. Software development companies prefer the Python language due to its versatile features and programming codes. Almost 14% of programmers use python in operating systems such as UNIX, Linux, Windows and Mac OS. The programmers of various famous companies use Python since it has created a brand in software development with characteristics such as:
• High level
• Extensible in C ++ & C
• Dynamic, Interpreted
Benefits of Python
• Support libraries: – It provides standard libraries that include string operations, web service tools, Internet, interfaces and operating system protocols.Most commonly used programming tasks are in a script that limits the length of the codes.
• Integration function: – Python integrates the integration of business applications that facilitates the development of web services by COM or COBRA components. Python can process XML and other markup languages since it can run on all operating systems through the same byte code.
• Productivity: – With its robust process integration capabilities, the unit testing framework and improved control capabilities help increase the speed for most applications and the productivity of applications. It is an excellent option to create scalable multiprotocol network applications.
The list is a data type available in python which is the most versatile data type; It can write as a list of values separated by commas. A list is that the elements of a list do not have to be of the same type.
Creating a list is as simple as placing different values separated by commas in brackets. For example
list1 = [‘physics’, ‘chemistry’, 1997, 2000];
list2 = [1, 2, 3, 4, 5];
list3 = [“a”, “b”, “c”, “d”]
Like string indexes, list indices start at 0, and lists can be divided, concatenated, etc.
Built-in List Functions
1. cmp(list1, list2):- Compare the elements of both given lists.
2. len(list):- Gives the total length of the given list.
3. max(list):- Find out maximum value from a list.
4. min(list):- Find out minimum value from a list.
5. list(seq):- Converts a row into a list.
Compare Lists using Set() and Cmp() Function in Python
The lists in python are making in different ways but depend on the required result. Two very common comparison methods are set () and cmp (). The set () function creates an object and Python compare two lists by cmp () function and return a value based on the past arguments.
Comparison function:- compares elements of two lists.
• list1 − the First list
• list2 − Second list
If the elements have the same type, perform the comparison and return the result. If the elements have different types, check if they are numbers.
• If they are numbers, perform numerical coercion if necessary and compare.
• If any of the elements is a number, then the other element is “larger” (the numbers are “smaller”).
• Otherwise, the types are sorted by name as per alphabetical manner.
Set function:-The set() function takes an argument and converts it to its object. It can take arguments such as lists, tuples and dictionaries. These arguments are called iterable. It is possible that the resulting set does not have the same order of elements. Two lists can compare using the set () function by passing them first as arguments. Once they converted into sets, operations such as subtraction are used to analyse.
Syntax with example :-def Difference (list1, list2):
List_dif = [i for i in list1 + list2 if i not in list1 or i not in list2]
Python has headed the lists in recent years about other programming languages such as C, C ++ and Java and this language is generally used by programmers. The language has undergone various changes since its launch 25 years ago, from that time many additional features are adding into it.