Senthil Kumaran S

Similar documents
Python. Jae-Gil Lee Based on the slides by K. Naik, M. Raju, and S. Bhatkar. December 28, Outline

Table of Contents EVALUATION COPY

Accelerating Information Technology Innovation

Accelerating Information Technology Innovation

Introduction to Python

Outline. Simple types in Python Collections Processing collections Strings Tips. 1 On Python language. 2 How to use Python. 3 Syntax of Python

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D

Interactive use. $ python. >>> print 'Hello, world!' Hello, world! >>> 3 $ Ctrl-D

Introduction to Python. Prof. Steven Ludtke

THE IF STATEMENT. The if statement is used to check a condition: if the condition is true, we run a block

The current topic: Python. Announcements. Python. Python

Some material adapted from Upenn cmpe391 slides and other sources

LECTURE 1. Getting Started with Python

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Rapid Application Development with

History Installing & Running Python Names & Assignment Sequences types: Lists, Tuples, and Strings Mutability

Python - Variable Types. John R. Woodward

CSCE 110 Programming I Basics of Python: Variables, Expressions, Input/Output

Introduction to Python: Data types. HORT Lecture 8 Instructor: Kranthi Varala

Python for ArcGIS. Lab 1.

And Parallelism. Parallelism in Prolog. OR Parallelism

CS 3813/718 Fall Python Programming. Professor Liang Huang.

Introduction to Python

Chris Simpkins (Georgia Tech) CS 2316 Data Manipulation for Engineers Python Overview 1 / 9

Python Programming Exercises 1

Python Crash-Course. C. Basso. Dipartimento di Informatica e Scienze dell Informazione Università di Genova. December 11, 2007

Introduction to Python - Part I CNV Lab

Python Programming, bridging course 2011

C++ for Python Programmers

Flow Control: Branches and loops

CSCE 110 Programming I

1. BASICS OF PYTHON. JHU Physics & Astronomy Python Workshop Lecturer: Mubdi Rahman

Python. Department of Computer Science And Engineering. European University Cyprus

Introduction to Python

Python for Non-programmers

Part III Appendices 165

Shell / Python Tutorial. CS279 Autumn 2017 Rishi Bedi

C and Programming Basics

Introduction to Python. Fang (Cherry) Liu Ph.D. Scien5fic Compu5ng Consultant PACE GATECH

CIS192: Python Programming

[Software Development] Python (Part A) Davide Balzarotti. Eurecom Sophia Antipolis, France

There are four numeric types: 1. Integers, represented as a 32 bit (or longer) quantity. Digits sequences (possibly) signed are integer literals:

Programming to Python

Jython. secondary. memory

27-Sep CSCI 2132 Software Development Lecture 10: Formatted Input and Output. Faculty of Computer Science, Dalhousie University. Lecture 10 p.

CS Advanced Unix Tools & Scripting

GE PROBLEM SOVING AND PYTHON PROGRAMMING. Question Bank UNIT 1 - ALGORITHMIC PROBLEM SOLVING

CS Introduction to Computational and Data Science. Instructor: Renzhi Cao Computer Science Department Pacific Lutheran University Spring 2017

DSC 201: Data Analysis & Visualization

Introduction to Scientific Python, CME 193 Jan. 9, web.stanford.edu/~ermartin/teaching/cme193-winter15

CHAPTER 2: Introduction to Python COMPUTER PROGRAMMING SKILLS

Physics 514 Basic Python Intro

High Level Scripting. Gino Tosti University & INFN Perugia. 06/09/2010 SciNeGhe Data Analysis Tutorial

Introductory Linux Course. Python I. Pavlin Mitev UPPMAX. Author: Nina Fischer Dept. for Cell and Molecular Biology, Uppsala University

Python Workshop. January 18, Chaitanya Talnikar. Saket Choudhary

Course Title: Python + Django for Web Application

Loops and Conditionals. HORT Lecture 11 Instructor: Kranthi Varala

CSI33 Data Structures

G Programming Languages - Fall 2012

Introduction to Python. Didzis Gosko

(CC)A-NC 2.5 by Randall Munroe Python

OOP and Scripting in Python

Princeton University COS 333: Advanced Programming Techniques A Subset of Python 2.7

AI Programming CS S-02 Python

Large-Scale Networks

CS S-02 Python 1. Most python references use examples involving spam, parrots (deceased), silly walks, and the like

ENGR 102 Engineering Lab I - Computation

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

The Compilation Process

The Pyth Language. Administrivia

2.Raspberry PI: Architecture & Hardware Specifications

Introduction to Python

CIS192 Python Programming. Robert Rand. August 27, 2015

Welcome to Python! Ilhoe Jung. Graphics & Media Lab

Key Differences Between Python and Java

Introduction to Python

18.1. CS 102 Unit 18. Python. Mark Redekopp

CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) First Name: Last Name: NetID:

Introductory Linux Course. Python I. Martin Dahlö UPPMAX. Author: Nina Fischer. Dept. for Cell and Molecular Biology, Uppsala University

Static Semantics. Lecture 15. (Notes by P. N. Hilfinger and R. Bodik) 2/29/08 Prof. Hilfinger, CS164 Lecture 15 1

Python Basics. Lecture and Lab 5 Day Course. Python Basics

PYTHON. Varun Jain & Senior Software Engineer. Pratap, Mysore Narasimha Raju & TEST AUTOMATION ARCHITECT. CenturyLink Technologies India PVT LTD

Multimedia-Programmierung Übung 1

PYTHON FOR MEDICAL PHYSICISTS. Radiation Oncology Medical Physics Cancer Care Services, Royal Brisbane & Women s Hospital

Computational Integer Programming. Lecture 4: Python. Dr. Ted Ralphs

Python for C programmers

Python for Earth Scientists

Conditionals and Recursion. Python Part 4

SD314 Outils pour le Big Data

Lecture 1. A. Sahu and S. V. Rao. Indian Institute of Technology Guwahati

Lecture 7: Python s Built-in. in Types and Basic Statements

What Version Number to Install

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

Python at Glance. a really fast (but complete) ride into the Python hole. Paolo Bellagente - ES3 - DII - UniBS

CS 330 Lecture 18. Symbol table. C scope rules. Declarations. Chapter 5 Louden Outline

Introduction to Python

Winter 2019 CISC101 1/17/2019

Introduction to Python Part 1. Brian Gregor Research Computing Services Information Services & Technology

Guido van Rossum 9th LASER summer school, Sept. 2012

Python: Short Overview and Recap

Transcription:

Senthil Kumaran S http://www.stylesen.org/

Agenda History Basics Control Flow Functions Modules

History

What is Python? Python is a general purpose, object-oriented, high level, interpreted language Created in early 90's by Guido Van Rossum Simple, portable and powerful Free Software Influenced by ABC, ALGOL 68, C, Haskell, Icon, Lisp, Modula-3, Perl, Java

Why learn Python? Easier to learn than compiled languages like C/C++ Fast development of POC code Cross Platform Batteries Included Great documentation Strong community support

Application domains Web and Internet development Database Access Desktop GUIs Scientific and Numeric Education Network Programming Software Development Games and 3D Graphics

Versions of Python Python 2.5 Python 2.6 Python 3.0 Why 2.5/2.6 and!3.0 Installing - Download from www.python.org - Most GNU/Linux distributions have it already

Editing Python IDLE Emacs Vi/Vim Whatever editor you want

Python Interpreter Interactive session Use of interactive session Exit python interpreter - quit() - Ctrl + D on *NIX - Ctrl + Z on Windows

Basics

Hello World $ emacs hello_world.py $ cat hello_world.py #!/usr/bin/python print "Hello World" $ chmod +x hello_world.py $./hello_world.py Hello World $ python Python 2.5.2 (r252:60911, Jan 4 2009, 17:40:26) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print "Hello World" Hello World >>>

Indentation Is very important in Python No begin/end delimiters Comments start with #

Data Types Integer Numbers Decimal 1, 3, 87 Octal - 01, 022 Hexa - 0x1, 0x22 Long - 1L, 456666343L Floating point 0.0, 400.34, 5e3, 45e5 Complex Numbers [j = (-1) 1/2 ] -1+5j, 5-6j

Strings print Hello World print 'Hello World' print Hello World' #Correct #Correct #Wrong print This is line one This is line two This is line three

Tuple Immutable ordered sequence of items Assigned a = (1234, 1456, 1212) Using tuples can be used as a constant array Data can be accessed similar to an array -> a=(132,3232,323) a[1] or a[2]

Lists List is a mutable ordered sequence of items (similar to tuple) Assigned-> a = [121,121212,34367] Using Lists -> simplest use is as arrays (but again much more) are Data can be accessed similar to an array -> a=[132,3232,323] a[1] or a[2]

Dictionaries Dictionaries are containers, which store items in a key/value pair(?) Assigned -> d ={'x':24,'y':33} Using Dict -> They are used at a lot of places Data can be accessed by using the key -> d['x']

Variables There is no prior declaration needed Variables are the references to the allocated memory Variables can refer to any data type (like Tuple, List,Dictionary, Int, String, Complex) References are share List,Dict etc are always shared

Index and slices String, List, Tuple, etc can be sliced to get a part of them Index -> similar to array index, it refers to 1 position of data Slices-> gives the data in the range Example -> a= Velalar College a[:3] a[4:11] a[4:] a[-7:] a[:-8] a[:11:2]

Control Flow

print Print is a simple statement for giving output similar to C's printf function Can be used to output to Console or a file Use -> print Hello World

input Use raw_input() to take a string input from the user Used as <var> = raw_input( Enter a String: ) Input() is used to take a input without specifying the type

If If is a conditional statement, for simple If then else clause in English Header lines are always concluded with a : followed by intended block of statements Optionally it can be followed by an else if clause known as elif in python if <condition>: Statement 1 Statement 2 elif <condition>: Statements else: statements

while While statement is used for repeatedly executing a block of code till the condition is true, also has an optional else clause Use wildly for infinite loop While <condition>: statements else: statements

for It is a sequence iterator It works on Strings, lists, tuples, etc For <target> in <iterable>: statements

range They are used to generate and return integer sequence Range(5) -> [0,1,2,3,4] Range(1,5) -> [1,2,3,4] Range(0,8,2) -> [0,2,4,6]

break Used to terminate a loop If nested it terminates the inner most loop Practically used for conditional loop termination with an if statement

continue Terminates the current iteration and executes next Practically used for conditional statements termination with an if statement

Some Helpful Functions Dir() Help()

Functions

What are functions? A Function is a group of statements that execute on request In Python Functions are Objects Defining a function -> def name(parameters): statement(s) Return types

Parameters Types of parameters Mandatory Parameters Optional parameters Default values Be careful when default value is a mutable object def a(x,y=[]): y.append(x) print y print a(12) print a(34) What just happened here?

Modules

Modules What are modules? How to load modules Effect on namespace Important modules - os - sys

Q&A? web : http://www.stylesen.org/