Upload
kernel-training
View
99
Download
8
Embed Size (px)
Citation preview
Python Language
Session 1Getting Started
AGENDA
Course Preview Introduction to Python Installation Data Types Examples/Practical Q&A
1. Course Preview
Module 1 : Introduction + Installation
Module 2 : Building Elements( Data types)
Module 3 : Control statements + Iterators
Module 4 : Logical statements + Application (1-4)
Module 5 : Functions
Module 6 : Collections ( list + tuples)
Module 7 : Collections continued(Maps,sets,enum)
Module 8 : Applications (5-7)
Module 9 : OOPS Concepts
Module 10 : Sharing code (modules)
Module 11 : File Operations
Module 12 : Exception Handling
Module 13 : Unit testing – Introduction to Robot Framework
2. Introduction to Python
Open Source Language Object Oriented, HLL,Interpreted etc Implemented in C Cross platform (Windows,Unix,Macintosh) Works on PC, Phones and Web Statement grouping by indentation Latest version 3.4.3 and 2.7.9
2. Introduction to Python (cont)
Extensive libraries are packaged together Memory Management – Garbage collection Integrates with C,C++ and Java. Implementation (Cpython, IronPython and
Jython)
3. Installation
Installation method are different depending on Operating system.
3.1 Unix Based System
a) Download source code from https://www.python.org/downloads/source/
b) Unzip; ./configure
c) make ; make install
Python is mostly pre-installed on most unix based systems. Generally binary are be found at /usr/bin/python and
3. Installation (cont)
3.2 Window Based system
a) Download the installer from https://www.python.org/downloads/windows/
b) Execute the binary file ,you need to administrator to execute the binary.
c) Now selection the installation path ; then do next and select components .
d) Set Environment variable.
My Computer Properties Advanced Environment ‣ ‣ ‣Variables . (Change it according to your installation path).
3. Installation (cont)
3.3 Mac
Python is part of Mac OS environment. Tiger (Mac OS 10.4) includes Python 2.3.5 and IDLE (Integrated Development Environment). Leopard (Mac OS 10.5) includes Python 2.5.1 ..
Python files can be found at /System/Library/Frameworks/Python.framework/Versions
Open terminal and type python.
4. Data Types
1. Integers : 32 Bit long ; range -2^32 to -2^32
2. Long Int :
3. Float Point (Double precision no) 64 bit
4. Boolean
5. Complex Number
6. Strings : Sequence of Unicode characters
7. Lists : Ordered Sequence of Values
8. Tuples : Ordered, immutable sequence of values
9. Sets : Unordered collections of values.
10. Dictionaries : Unordered collections of key-value pairs.
Note: Unicode is standard that uses 16 bit characters to represent characters on computer. ASCII (American Standard code of information Interchange) uses 8 bit.
Before we start coding..
1. Comments : Single line or multi lines
Single line – Begin with “#”
Multi line – Begin with triple quoted strings
'''this is comments
'''
2. Printing : We use print function.
Print(“Hello World”) ## string
Print (20) ## integer
Print(g) ## literal value
print(“Length is:”,l) # string + liternal ;
Print (“first” + “second”) ## concatenate
print(“first value is %d and second value is %d” %(f,s)) ## using format code % for substituting values in the variables at desired places. f and s are of integer type. Similarly %s for string,%e for exponential , %f for floating point, %o octal base 8, %x hexadecimal and %c for ASCII code.
5. Examples
1. Hello world
2. Addition of Numbers
3. Few more examples .
6. Q&A
Forum is open