What is Python
Python is an interpreted, object-oriented, high-level level programming language with dynamic semantics. Python was developed by Guido Van Rossum in the late eighties and early nineties at the National Research Institute for Mathematics and Computer Science in the Netherlands.
Features of Python:-
- Less line of codes than other languages (fast execution of Ideas)
- Platform independent
- Open Source
- Object Oriented
- It supports functional and structured programming methods
- It can be used as a scripting language or can be compiled to byte-code for building large applications
- It provides very high-level
- level dynamic data types and supports dynamic type checking
- It supports automatic garbage collection
- It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java
What big companies use Python?
- Google (Youtube)
- Facebook (Tornado)
- Dropbox.
- Yahoo.
- NASA.
- IBM.
- Mozilla.
- Quora
Google written in Python?
Google App Engine is an eminent sample of Python–written application, it allows
building web applications with Python programming language, using its rich collection
of libraries, tools and frameworks. Python is everywhere at YouTube.
code.google.com – main website for Google developers.
Is Python for web development?
Python can be used to build server-side web applications. While a web framework is not
required to build web apps, it’s rare that developers would not use existing open source
libraries to speed up their progress in getting their application working. Python is not
used in a web browser.
What is the framework for Python?
“What is a web framework?” is an in-depth explanation of what web frameworks are
and their relation to web servers. Django vs Flask vs Pyramid: Choosing a Python Web Framework contains background information and code comparisons for similar web applications built in these three big Python frameworks
Installing Python in Linux:
If you are using Ubuntu 16.10 or newer, then you can easily install Python 3.6 with the following commands:
$ sudo apt-get update $ sudo apt-get install python3.6
To see which version of Python 3 you have installed, open a terminal and run
$ python3 --version
If you are using other Linux distribution, chances are you already have Python 3 pre-installed as well. If not, use your distribution’s package manager. For example on Fedora, you would use dnf:
$ sudo dnf install python3
For more: Refer to this link.
Installing Python in Windows:
How to start the Python?
First of all install the Python 2.7.12 on your system. After installation it will create a
directory in C: drive named Python27. In Python27 there is a file python.exe. Copy the path of python.exe from address bar.
To set the path of python in “path” system variable:
- Copy the path of python.exe from address bar.
- Right click on Computer then click on Properties
- Click on Advanced System Settings then click on Environment Variables.
- Choose path variable and click on Edit button.
- Deselect the path and stuff a semicolon at last and paste the copied path.
- Now click on OK button.
First Python Program:-
Open the command prompt, type python and press enter key. The python prompt will open. Now type the following code:
code:
print “Hello Python!”
Press enter key it will display following output:-
output:
Hello Python!
Make simple calculator using python:-
On command prompt make a directory PythonProgs using md command.
Then use cd command to open PythonProgs directory.
Now type notepad SimpleCalc.py. The notepad editor will open and type the following code:
code:
a=input(“Enter first number : ”)
b=input(“Enter first number : ”)
print “Summation = ”,(a+b)
print “Subtraction = ”(a-b)
print “Multiplication = ”(a*b)
print “Division = ”,(a/b)
Now save the file SimpleCalc.py and close the file.
Now at command prompt type python SimpleCalc.py it display the following output:-
output:
Enter first number : 10
Enter second number : 5
Summation = 15
Subtraction = 5
Multiplication = 50
Division = 2
What is the return in Python?
The print() function writes, i.e., “prints”, a string in the console. The return statement causes your function to exit and hand back a value to its caller. The point of functions in general is to take in inputs and return something. The return statement is used when a function is ready to return a value to its caller.
What is the input function in Python?
Input can come in various ways, for example from a database, another computer, mouse clicks and movements or from the internet. Yet, in most cases the input stems from the keyboard. For this purpose, Python provides the function input(). Input has an optional parameter, which is the prompt string.
Do you need semicolons in Python?
Python does not require semi-colons to terminate statements. You can also use them
at the end of a line, which makes them look like a statement terminator, but this is legal
only because blank statements are legal in Python — a line that contains asemicolon at
the end is two statements, the second one blank.
Applications for Python
Web and Internet Development
Python offers many choices for web development:
- Frameworks such as Django and Pyramid.
- Micro-frameworks such as Flask and Bottle.
- Advanced content management systems such as Plone and django CMS.
Python’s standard library supports many Internet protocols:
- HTML and XML
- JSON
- E-mail processing.
- Support for FTP, IMAP, and other Internet protocols.
- Easy-to-use socket interface.
And the Package Index has yet more libraries:
- Requests, a powerful HTTP client library.
- BeautifulSoup, an HTML parser that can handle all sorts of oddball HTML.
- Feedparser for parsing RSS/Atom feeds.
- Paramiko, implementing the SSH2 protocol.
- Twisted Python, a framework for asynchronous network programming.
Scientific and Numeric
Python is widely used in scientific and numeric computing:
- SciPy is a collection of packages for mathematics, science, and engineering.
- Pandas is a data analysis and modeling library.
- IPython is a powerful interactive shell that features easy editing and recording of a work session, and supports visualizations and parallel computing.
- The Software Carpentry Course teaches basic skills for scientific computing, running bootcamps and providing open-access teaching materials.
Education
Python is a superb language for teaching programming, both at the introductory level and in more advanced courses.
- Books such as How to Think Like a Computer Scientist, Python Programming: An Introduction to Computer Science, and Practical Programming.
- The Education Special Interest Group is a good place to discuss teaching issues.