Intro to Python
Intro to Python
various applications.
Python is an easy language to
Interpreted
learn because of its simple syntax
Python can be used for simple
tasks such as plotting or for more
complex tasks like machine Object Oriented
learning. Scripting Language
Business
Applications
4 3 Software
Development
Why do people use python?
The following primary factors cited by python users seem to be these:
Python is object-oriented
Structure supports such concepts as polymorphism operation
overloading & multiple inheritance
Its free (Open source)
Downloading and installing python is free and easy source code is
easily accessible.
It’s powerful
Dynamic typing
Build-in types & tools
library utility
Third party utility (e.g. Numeric, NumPy, SciPy)
Automatic memory management
It’s portable
Python runs virtually every major platform used today
As long as you have a compatible python interpreter installed, python programmes will
run in exactly the same manner, irrespective of platform.
Popular website build with Python
Reddit
YouTube Instagram
Google
Dropbox
Quora Pinterest
Installing Python IDE
Python is pre-installed on most Unix systems, including Linux and MAC OS X
But for in Windows operating systems , user can download from the
http://www.python.org/downloads/
- From the above link download the latest version of python IDE and install,
recent version is 3.4.1 but most of them uses version 2.7.7 only
Installing Python on Windows
Step: 1
❑ To download and install Python, go to Python's official
website http://www.python.org/downloads/
Step: 2
❑ When download is complete run .exe file to install
Python.
Step: 3
❑ You can see python installation.
Step: 4
❑ when installation was complete you can see message
“setup was successful” on screen.
IDLE Development Environment
❑ Integrated DeveLopment Environment
Byte Virtual
Compiler
Code Machine
Source code
Running
Code
Library
Module
Running Python
Once you are inside the Python interpreter, type in commands at will.
Examples:
>>> print ‘Hello world’
Hello world
Datatypes
Text Type: str
a = [ “python", a = ( “python",
a=2x “Java", “Html“ ] “Java", “Html“ )
dict set bool
a={
"name" : “Amit", a = { “python", a=True
“Java", “Html“ }
"age" : 25 }
❑ Floats
a=5/2 #answer is 2.5
❑ Strings
Can use “ ” or ‘ ’ to specify.
“GKTCS” or ‘GKTCS’ are same.
String Methods
title() upper() lower()
Variable names are case-sensitive (age, Age and AGE are three
different variables)
Function Syntax
def...: indicates that you are defining a new function.
function() refers to the name of your function. By convention, this name is typically lowercase and represents a verb/action.
a,b refers to parameters (values or variables) that can be used within the statements of your function’s definition (......). If your function has no parameters, an
empty parenthetical () is used.
The return statement is an optional statement that will return a value for your function to your original call.
2) Multi-line comments
Created by adding a delimiter (""") on each end of the comment.
The parameter for an input function is called a prompt. This is a string (this can be indicated by “” or ‘’) such as “Enter a number: “
The user’s response to the prompt will be returned to the input statement call as a string. To use this value as any other data type, it must be
converted with another function (int()).
Print functions (print()) allow programs to output strings to users on a given interface.
The parameter of this function is of any type. All types will automatically be converted to strings.