2. CONTENTS
INTRODUCTION
PROBLEM SOLVING TECHNIQUES
ALGORITHMIC STRATEGIES
FUNCTIONS
PYTHON – VARIABLES AND OPERATORS
CONTROL STRUCTURES
STRINGS AND STRING MANIPULATION
LIST,TUPLES AND DICTIONARY
3. INTRODUCTION
Python is a general-purpose interpreted, interactive,
object-oriented, and high-level programming
language.
It was created by Guido van Rossum during 1985- 1990
4. Why to Learn Python?
Python is a high-level, interpreted, interactive and
object-oriented scripting language.
Designed- highly readable.
Uses English Keywords frequently.
To become a great Software Engineer – Web
Development Domain.
Python is Interpreted
Python is Interactive
Python is Object-Oriented
Python is a Beginner's Language
5. Applications of Python
Easy-to-learn
Easy-to-read
Easy-to-maintain
Interactive Mode
Portable
OpenSource
Real Time Applications
Bit Torrent file sharing
Google search engine, YouTube
Face book, Drop box
6. PROBLEM SOLVING TECHNIQUES
Define the problem and creating number of solutions.
Starts –Problem specification, Ends – Correct
Program.
PROBLEM SOLVING TECHNIQUES
• Set of techniques that helps in providing logic –solve
the problem.
1. Algorithms.
2. Flowcharts.
3. Pseudo codes.
4. Programs
7. ALGORITHM
Sequence of instructions that describe a method.
Qualities of an Algorithm:
Should be written in simple English
Should be precise and unambiguous.
Should not be repeated infinitely.
should conclude after a finite number of steps.
Should have an end point
Derived results should be obtained only after the
algorithm terminates.
8. Example:
Addition of Two Numbers:
1.Start
2. Read the value of ‘a’
3. Read the value of ‘b’
4. Calculate sum=a+b
5. Print the sum of two number
6. Stop
14. FUNCTIONS
Block of organized, reusable code that is used to
perform a single, related action.
Methods, sub-routines.
Syntax
function_name(parameters)
function statements
end function
15. Algorithm for addition of two
numbers using function
Main function()
Step 1: Start
Step 2:Call the function add()
Step 3: Stop
• Sub function add()
Step1:Functionstart
Step2:Geta,bValues
Step 3: add c=a+b
Step 4: Print c
Step 5: Return
16. VARIABLES:
Store a value by assigning it to a name.
It can be of any length. No space is allowed
Assigning value to variable:
>>>counter =45
print (counter)
single value to several variables
a=b=c=100
Multiple values to multiple variables
>>>a,b,c=2,4,"ram"
17. OPERATORS
Constructs which can manipulate the value of operands.
expression 4 + 5 = 9
Types of Operators
Arithmetic Operators
Comparison (Relational)Operators
Assignment Operators
Logical Operators
Bitwise Operators
Membership Operators
Identity Operators
31. STRINGS AND STRING MANIPULATION
Series or sequence of characters
Strings are marked by quotes:
Single quotes(' ') E.g., 'This a string in single quotes'
Double quotes(" ") E.g., "'This a string in double quotes‘”
Triple quotes(""" """)E.g., """This is a paragraph. It is
made up of multiple lines and sentences.""“
Strings are Immutable
33. Lists
List is an ordered sequence of items
square brackets[]
Items in the lists can be of different datatypes
Operations on list: Indexing, Slicing ,Concatenation
Repetitions, Updation, Insertion, Deletion
35. Tuple:
A tuple is same as list
Parentheses()
A tuple is an immutable list
Benefit of Tuple:
Tuples are faster than lists.
If the user wants to protect the data from accidental changes,
tuple can be used