SlideShare a Scribd company logo
PYTHON 2.7.3
Jibin Sabu
jibinsabu@ieee.org
+918129778871
What is Python?
Python is an easy to learn, powerful programming language. It has efficient high-level data
structures and a simple but effective approach to object-oriented programming. Python’s
elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal
language for scripting and rapid application development in many areas on most platforms.The
Python interpreter and the extensive standard library are freely available in source or binary
form for all major platforms from the Python Web site,http://www.python.org/, and may be
freely distributed. The same site also contains distributions of and pointers to many free third
party Python modules, programs and tools, and additional documentation.
Objective of the Workshop:
To make you able to read and write Python modules and programs, and also make you ready
to learn more about the various Python library modules described in The Python Standard
Library.
Start
->start a new terminal
->type “python”
it will display the version of python installed in
your system

-> you can start your programming
in python here (>>>)

Happy programming!!!
Comments in python
Comments in Python start with the hash
character, #, and extend to the end of the
physical line. A comment may appear at
the start of a line or following whitespace
or code, but not within a string literal. A
hash character within a string literal is just
a hash character. Since comments are to
clarify code and are not interpreted by
Python, they may be omitted when typing
in examples.
Numbers
-> The interpreter acts just as a
calculator. you can enter the
numbers and do math.
->”=” is used to assign a variable.
-> if both numbers are given as int
data type, ie by default. the resultant
will also be int
therefore n/m=2.
->if any number is of float type, the
resultant will be float type
->variable must be assigned before
using, else error occurs
->we can also have multiple variable
assignments.
complex numbers
->Complex numbers are also supported;
imaginary numbers are written with a suffix
of j or J. Complex numbers with a nonzero
real component are written as(real+imag j
), or can be created with the
complex(real, imag) function.
->Complex numbers are always
represented as two floating point numbers,
the real and imaginary part. To extract
these parts from a complex number z, use
z.real and z.imag.
->abs gives the absolute value.
->Can’t convert complex to other data type
using functions like float(z) etc.
Result of prev. calc
->In interactive mode, the last printed
expression is assigned to the variable
_. This means that when you are
using Python as a desk calculator, it
is somewhat easier to continue
calculations.
->round(n,m) function is used to
round a number n, to m decimal
places
Strings
-> They can be enclosed in single quotes
or double quotes
-> easy merging of lines.
-> easy concatenation
string.... contd
Strings can be subscripted (indexed); like in C, the first character of a string has subscript (index) 0. There
is no separate character type; a character is simply a string of size one. Like in Icon, substrings can be
specified with the slice notation: two indices separated by a colon.Slice indices have useful defaults; an
omitted first index defaults to zero, an omitted second index defaults to the size of the string being sliced.
Unlike a C string, Python strings cannot be changed. Assigning to an indexed position in the string results
in an error:However, creating a new string with the combined content is easy and efficient:Here’s a useful
invariant of slice operations: s[:i] + s[i:] equals s.Degenerate slice indices are handled gracefully: an index
that is too large is replaced by the string size, an upper bound smaller than the lower bound returns an
empty string.Indices may be negative numbers, to start counting from the right. But note that -0 is really
the same as 0, so it does not count from the right!
Out-of-range negative slice indices are truncated, but don’t try this for single-element (non-slice) indices:
string contd..
List
->Python knows a number of compound data
types, used to group together other values. The
most versatile is the list, which can be written as
a list of comma-separated values (items)
between square brackets. List items need not all
have the same type.
->Like string indices, list indices start at 0, and
lists can be sliced, concatenated and so on:
->Unlike strings, which are immutable, it is
possible to change individual elements of a list:
->Assignment to slices is also possible, and this
can even change the size of the list or clear it
entirely:
->The built-in function len() also applies to lists:
First Steps Towards Programming
Fibonacci series
-> The number will be the sum of the previous two number’s.
initialise first two numbers as 0,1.
The while loop executes as long as the condition (here: b < 10) remains true. In Python,
like in C, any non-zero integer value is true; zero is false. The condition may also be a
string or list value, in fact any sequence; anything with a non-zero length is true, empty
sequences are false. The test used in the example is a simple comparison. The standard
comparison operators are written the same as in C: < (less than), > (greater than), ==
(equal to), <=(less than or equal to), >= (greater than or equal to) and != (not equal to).
Program

try without ;
trailing , avoids new line

More Related Content

PPTX
FUNDAMENTAL OF C
PPT
Beginner C++ easy slide and simple definition with questions
PPT
Beginner C++ easy slide and simple definition with questions
PPTX
Data Type in C Programming
PPSX
Getting started with c++.pptx
PPTX
C data type format specifier
PPTX
Cpu-fundamental of C
PPTX
LISP: Input And Output
FUNDAMENTAL OF C
Beginner C++ easy slide and simple definition with questions
Beginner C++ easy slide and simple definition with questions
Data Type in C Programming
Getting started with c++.pptx
C data type format specifier
Cpu-fundamental of C
LISP: Input And Output

What's hot (20)

PPTX
C Tokens
PPT
Data types and Operators
PPTX
Ch8 Arrays
PPTX
Numeric Data Types & Strings
PDF
USER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdf
PPTX
Datatype in c++ unit 3 -topic 2
PPTX
Data types in C language
PDF
[ITP - Lecture 05] Datatypes
PPTX
Operators in C Programming
PDF
Development of a static code analyzer for detecting errors of porting program...
PPT
C++ data types
PPT
Pointer introduction day1
PDF
Variables and data types IN SWIFT
PPT
Escape Sequences and Variables
PDF
C programming | Class 8 | III Term
PPT
C language Unit 2 Slides, UPTU C language
PPTX
datatypes and variables in c language
PPT
Getting started with c++
PPTX
Basic concepts of python
PPT
Basic concept of c++
C Tokens
Data types and Operators
Ch8 Arrays
Numeric Data Types & Strings
USER DEFINED FUNCTIONS IN C MRS.SOWMYA JYOTHI.pdf
Datatype in c++ unit 3 -topic 2
Data types in C language
[ITP - Lecture 05] Datatypes
Operators in C Programming
Development of a static code analyzer for detecting errors of porting program...
C++ data types
Pointer introduction day1
Variables and data types IN SWIFT
Escape Sequences and Variables
C programming | Class 8 | III Term
C language Unit 2 Slides, UPTU C language
datatypes and variables in c language
Getting started with c++
Basic concepts of python
Basic concept of c++
Ad

Viewers also liked (11)

PDF
Maintain and share your python project (維護和分享 Python 程式專案)
PPTX
Python programming - Everyday(ish) Examples
DOCX
Mythological calender using C++
DOC
Calender for the project
PDF
Intro to Python
PDF
Intro to Python Workshop San Diego, CA (January 19, 2013)
PDF
Python Puzzlers
PDF
Python Workshop. LUG Maniapl
PPTX
First python project
PDF
Workshop programs
PDF
From NASA to Startups to Big Commerce
Maintain and share your python project (維護和分享 Python 程式專案)
Python programming - Everyday(ish) Examples
Mythological calender using C++
Calender for the project
Intro to Python
Intro to Python Workshop San Diego, CA (January 19, 2013)
Python Puzzlers
Python Workshop. LUG Maniapl
First python project
Workshop programs
From NASA to Startups to Big Commerce
Ad

Similar to Python workshop (20)

PPTX
Engineering CS 5th Sem Python Module-1.pptx
PDF
data base nd analystics slybysss for the students to improbvr
DOCX
c++ best code.docxhsdsdcvcdcdvdvdvdvdcdv
PDF
Python Objects
PPTX
Python unit 1 (1).pptx
PDF
Python Interview Questions PDF By ScholarHat.pdf
PPTX
Python PPT2
PPTX
Programming Basics.pptx
PPTX
Introduction to Python for Data Science and Machine Learning
PPTX
Intro to Python Programming Language
PDF
problem solving and python programming UNIT 2.pdf
PDF
Problem Solving and Python Programming UNIT 2.pdf
PPTX
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
PPTX
Structure of c_program_to_input_output
ODP
Python slide.1
PPT
Python Built-in Functions and Use cases
PDF
Python_Unit_1.pdf
PPTX
Introduction on basic python and it's application
PDF
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
PPTX
Introduction to Python Part-1
Engineering CS 5th Sem Python Module-1.pptx
data base nd analystics slybysss for the students to improbvr
c++ best code.docxhsdsdcvcdcdvdvdvdvdcdv
Python Objects
Python unit 1 (1).pptx
Python Interview Questions PDF By ScholarHat.pdf
Python PPT2
Programming Basics.pptx
Introduction to Python for Data Science and Machine Learning
Intro to Python Programming Language
problem solving and python programming UNIT 2.pdf
Problem Solving and Python Programming UNIT 2.pdf
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
Structure of c_program_to_input_output
Python slide.1
Python Built-in Functions and Use cases
Python_Unit_1.pdf
Introduction on basic python and it's application
python-online&offline-training-in-kphb-hyderabad (1) (1).pdf
Introduction to Python Part-1

Recently uploaded (20)

PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Pre independence Education in Inndia.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
01-Introduction-to-Information-Management.pdf
PDF
Basic Mud Logging Guide for educational purpose
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Insiders guide to clinical Medicine.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
Microbial diseases, their pathogenesis and prophylaxis
Final Presentation General Medicine 03-08-2024.pptx
Pre independence Education in Inndia.pdf
Institutional Correction lecture only . . .
human mycosis Human fungal infections are called human mycosis..pptx
Renaissance Architecture: A Journey from Faith to Humanism
PPH.pptx obstetrics and gynecology in nursing
01-Introduction-to-Information-Management.pdf
Basic Mud Logging Guide for educational purpose
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Insiders guide to clinical Medicine.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
O7-L3 Supply Chain Operations - ICLT Program
VCE English Exam - Section C Student Revision Booklet
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
102 student loan defaulters named and shamed – Is someone you know on the list?

Python workshop

  • 2. What is Python? Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.The Python interpreter and the extensive standard library are freely available in source or binary form for all major platforms from the Python Web site,http://www.python.org/, and may be freely distributed. The same site also contains distributions of and pointers to many free third party Python modules, programs and tools, and additional documentation. Objective of the Workshop: To make you able to read and write Python modules and programs, and also make you ready to learn more about the various Python library modules described in The Python Standard Library.
  • 3. Start ->start a new terminal ->type “python” it will display the version of python installed in your system -> you can start your programming in python here (>>>) Happy programming!!!
  • 4. Comments in python Comments in Python start with the hash character, #, and extend to the end of the physical line. A comment may appear at the start of a line or following whitespace or code, but not within a string literal. A hash character within a string literal is just a hash character. Since comments are to clarify code and are not interpreted by Python, they may be omitted when typing in examples.
  • 5. Numbers -> The interpreter acts just as a calculator. you can enter the numbers and do math. ->”=” is used to assign a variable. -> if both numbers are given as int data type, ie by default. the resultant will also be int therefore n/m=2. ->if any number is of float type, the resultant will be float type ->variable must be assigned before using, else error occurs ->we can also have multiple variable assignments.
  • 6. complex numbers ->Complex numbers are also supported; imaginary numbers are written with a suffix of j or J. Complex numbers with a nonzero real component are written as(real+imag j ), or can be created with the complex(real, imag) function. ->Complex numbers are always represented as two floating point numbers, the real and imaginary part. To extract these parts from a complex number z, use z.real and z.imag. ->abs gives the absolute value. ->Can’t convert complex to other data type using functions like float(z) etc.
  • 7. Result of prev. calc ->In interactive mode, the last printed expression is assigned to the variable _. This means that when you are using Python as a desk calculator, it is somewhat easier to continue calculations. ->round(n,m) function is used to round a number n, to m decimal places
  • 8. Strings -> They can be enclosed in single quotes or double quotes -> easy merging of lines. -> easy concatenation
  • 9. string.... contd Strings can be subscripted (indexed); like in C, the first character of a string has subscript (index) 0. There is no separate character type; a character is simply a string of size one. Like in Icon, substrings can be specified with the slice notation: two indices separated by a colon.Slice indices have useful defaults; an omitted first index defaults to zero, an omitted second index defaults to the size of the string being sliced. Unlike a C string, Python strings cannot be changed. Assigning to an indexed position in the string results in an error:However, creating a new string with the combined content is easy and efficient:Here’s a useful invariant of slice operations: s[:i] + s[i:] equals s.Degenerate slice indices are handled gracefully: an index that is too large is replaced by the string size, an upper bound smaller than the lower bound returns an empty string.Indices may be negative numbers, to start counting from the right. But note that -0 is really the same as 0, so it does not count from the right! Out-of-range negative slice indices are truncated, but don’t try this for single-element (non-slice) indices:
  • 11. List ->Python knows a number of compound data types, used to group together other values. The most versatile is the list, which can be written as a list of comma-separated values (items) between square brackets. List items need not all have the same type. ->Like string indices, list indices start at 0, and lists can be sliced, concatenated and so on: ->Unlike strings, which are immutable, it is possible to change individual elements of a list: ->Assignment to slices is also possible, and this can even change the size of the list or clear it entirely: ->The built-in function len() also applies to lists:
  • 12. First Steps Towards Programming
  • 13. Fibonacci series -> The number will be the sum of the previous two number’s. initialise first two numbers as 0,1. The while loop executes as long as the condition (here: b < 10) remains true. In Python, like in C, any non-zero integer value is true; zero is false. The condition may also be a string or list value, in fact any sequence; anything with a non-zero length is true, empty sequences are false. The test used in the example is a simple comparison. The standard comparison operators are written the same as in C: < (less than), > (greater than), == (equal to), <=(less than or equal to), >= (greater than or equal to) and != (not equal to).
  • 14. Program try without ; trailing , avoids new line