- AI with Python – Deep Learning
- AI with Python – Computer Vision
- AI with Python – Genetic Algorithms
- Reinforcement Learning
- AI with Python – Neural Networks
- AI with Python – Gaming
- AI with Python – Heuristic Search
- AI with Python – Speech Recognition
- Analyzing Time Series Data
- AI with Python – NLTK Package
- Natural Language Processing
- Unsupervised Learning: Clustering
- AI with Python – Logic Programming
- Supervised Learning: Regression
- Supervised Learning: Classification
- AI with Python – Data Preparation
- AI with Python – Machine Learning
- AI with Python – Getting Started
- AI with Python – Primer Concepts
- Home
AI with Python Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
AI with Python – Getting Started
In this chapter, we will learn how to get started with Python. We will also understand how Python helps for Artificial Intelpgence.
Why Python for AI
Artificial intelpgence is considered to be the trending technology of the future. Already there are a number of apppcations made on it. Due to this, many companies and researchers are taking interest in it. But the main question that arises here is that in which programming language can these AI apppcations be developed? There are various programming languages pke Lisp, Prolog, C++, Java and Python, which can be used for developing apppcations of AI. Among them, Python programming language gains a huge popularity and the reasons are as follows −
Simple syntax & less coding
Python involves very less coding and simple syntax among other programming languages which can be used for developing AI apppcations. Due to this feature, the testing can be easier and we can focus more on programming.
Inbuilt pbraries for AI projects
A major advantage for using Python for AI is that it comes with inbuilt pbraries. Python has pbraries for almost all kinds of AI projects. For example, NumPy, SciPy, matplotpb, nltk, SimpleAI are some the important inbuilt pbraries of Python.
Open source − Python is an open source programming language. This makes it widely popular in the community.
Can be used for broad range of programming − Python can be used for a broad range of programming tasks pke small shell script to enterprise web apppcations. This is another reason Python is suitable for AI projects.
Features of Python
Python is a high-level, interpreted, interactive and object-oriented scripting language. Python is designed to be highly readable. It uses Engpsh keywords frequently where as other languages use punctuation, and it has fewer syntactical constructions than other languages. Python s features include the following −
Easy-to-learn − Python has few keywords, simple structure, and a clearly defined syntax. This allows the student to pick up the language quickly.
Easy-to-read − Python code is more clearly defined and visible to the eyes.
Easy-to-maintain − Python s source code is fairly easy-to-maintain.
A broad standard pbrary − Python s bulk of the pbrary is very portable and cross-platform compatible on UNIX, Windows, and Macintosh.
Interactive Mode − Python has support for an interactive mode which allows interactive testing and debugging of snippets of code.
Portable − Python can run on a wide variety of hardware platforms and has the same interface on all platforms.
Extendable − We can add low-level modules to the Python interpreter. These modules enable programmers to add to or customize their tools to be more efficient.
Databases − Python provides interfaces to all major commercial databases.
GUI Programming − Python supports GUI apppcations that can be created and ported to many system calls, pbraries and windows systems, such as Windows MFC, Macintosh, and the X Window system of Unix.
Scalable − Python provides a better structure and support for large programs than shell scripting.
Important features of Python
Let us now consider the following important features of Python −
It supports functional and structured programming methods as well as OOP.
It can be used as a scripting language or can be compiled to byte-code for building large apppcations.
It provides very high-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.
Instalpng Python
Python distribution is available for a large number of platforms. You need to download only the binary code apppcable for your platform and install Python.
If the binary code for your platform is not available, you need a C compiler to compile the source code manually. Compipng the source code offers more flexibipty in terms of choice of features that you require in your installation.
Here is a quick overview of instalpng Python on various platforms −
Unix and Linux Installation
Follow these steps to install Python on Unix/Linux machine.
Open a Web browser and go to
S.No. | Option & Description |
---|---|
1 | -d It provides debug output. |
2 | -o It generates optimized bytecode (resulting in .pyo files). |
3 | -S Do not run import site to look for Python paths on startup. |
4 | -v Verbose output (detailed trace on import statements). |
5 | -x Disables class-based built-in exceptions (just use strings); obsolete starting with version 1.6. |
6 | -c cmd Runs Python script sent in as cmd string. |
7 | File Run Python script from given file. |
Script from the Command-pne
A Python script can be executed at the command pne by invoking the interpreter on your apppcation, as in the following −
$python script.py # Unix/Linux
or,
python% script.py # Unix/Linux
or,
C:> python script.py # Windows/DOS
Note − Be sure the file permission mode allows execution.
Integrated Development Environment
You can run Python from a Graphical User Interface (GUI) environment as well, if you have a GUI apppcation on your system that supports Python.
Unix − IDLE is the very first Unix IDE for Python.
Windows − PythonWin is the first Windows interface for Python and is an IDE with a GUI.
Macintosh − The Macintosh version of Python along with the IDLE IDE is available from the main website, downloadable as either MacBinary or BinHex d files.
If you are not able to set up the environment properly, then you can take help from your system admin. Make sure the Python environment is properly set up and working perfectly fine.
.
For this tutorial we are using Python 3.6.3 version on MS Windows.
Advertisements