
Python is an interpreted, high-level, general-purpose programming language.
Python is a cross-platform programming language, meaning, it runs on multiple platforms like Windows, Mac OS X, Linux etc.
Python was introduced to the world in the year 1991 by Guido van Rossum
- Simple and easy to Learn:
- Python is simple language & easy to learn. write the following code in helloWorld.py file
print("Hello world!"); //Output Hello world!
Run the above code - python helloWorld.py
Congratulations! You just wrote your first program in Python
- Without having any other programming languages knowledge, you can learn python directly.
- Python is simple language & easy to learn. write the following code in helloWorld.py file
- Free and Open Source:
- Python is a open source language, so that anyone can use the python software without purchasing licence.
- Anyone can read the python source code and can able to do the modification in the source code and also we can redistribute that code to others.
- High Level Language:
- Python is a High Level Programming Language.
- It is easy to write and maintain programs written in High Level Language.
- Python is Interpreted Language:
- Like PHP, Python is also Interpreted language.
- Python interpreter is responsible for execution of python applications.
- Portable & Platform Independent:
- The python applications are portable. The applications which are developed by python on one platform are going to execute any platform without making any changes.
- To achieve the portability feature with respect to the every operating system a separate python software is developed for every version of python.
- Embeddable Language:
- We can embed the python code into other languages such as C,C++, Java and etc..
- In order to provide the scripting capabilities to other languages we can use the python code in it.
- Extensive Support Libraries:It provides large standard libraries that include the areas like string operations, Internet, web service tools, operating system interfaces and protocols. Most of the highly used programming tasks are already scripted into it that limits the length of the codes to be written in Python.
- Built-in Data Structure:It contains lots of data structure like lists, numbers & dictionaries.
A namespace is a mapping from names to objects. Python implements namespaces as dictionaries
- Number
- String
- List
- Tuple
- List
- Sets
- Dictionary
- Boolean
Lists | Tuples |
Lists are mutable, i.e. they can be edited. | Tuples are immutable, i.e. they cannot be edited. |
Lists are slower than tuples. | Tuples are faster than lists. |
Syntax: myList = [1,5,10] | Syntax: myTuple = (1,5,10) |
Dictionary is an unordered collection of elements. Elements in dictionary are stored as key value pair. Dictionary are indexed by keys.
Modules is a set of related functionalities
- Built-in Modules:
There are several built-in modules in Python, which you can import whenever you like
Import and use the platform module:
import platform x = platform.system() print("Platform is: " + x) - Custom Modules:
You can create your own custom module if required
To create a module just save the code you want in a file with the file extension .py e.g. - mymodule.py
def sayHello(name): print("Hello, " + name + " Welcome To Python Interview Questions")You can import your custom module whenever you like to use.
import mymodule mymodule.sayHello("Full Stack Tutorials")
- A lambda function is a small anonymous function.
- A lambda function can take any number of arguments, but can only have one expression.
A lambda function that sums argument a and b and print the result:
lists are mutable whereas tuples are immutable.
Negative index is used in python to index starting from the last element of the list, tuple or any other container class which supports indexing.
Python sequences can be index in positive and negative numbers. positive index - 0,1,2,3 etc and negative index - -1,-2,-3 etc. -1 refers to the last index, -2 refers to the second last index and so on.
Using # character.
Docstrings are not actually comments, but, they are documentation strings. docstrings always written within triple quotes