This document provides an introduction to Python programming. It discusses problem solving techniques like algorithms, flowcharts, and pseudocode. It also covers Python concepts like variables, operators, control structures, strings, lists, tuples, and dictionaries. Functions and algorithms are presented as ways to organize Python code. The document is intended as an introductory guide to learning Python programming.
Introduces Python as a high-level, interpreted, and object-oriented language. Highlights its applications in web development and ease of learning.
Describes problem-solving techniques including algorithms, flowcharts, pseudocode, and programming. Emphasizes defining and structuring solutions.
Introduces functions as reusable code blocks with an example of an addition operation using function structure.
Explains variables for value storage and types of operators used in Python such as arithmetic, comparison, and logical operators.Covers conditional statements in Python including if, else, elif, and nesting of conditions with examples.
Discusses strings as immutable sequences of characters and basic operations that can be performed on strings.
Examines data structures including lists (ordered), tuples (immutable), and dictionaries (unordered) with their characteristics and operations.
CONTENTS
INTRODUCTION
PROBLEMSOLVING TECHNIQUES
ALGORITHMIC STRATEGIES
FUNCTIONS
PYTHON – VARIABLES AND OPERATORS
CONTROL STRUCTURES
STRINGS AND STRING MANIPULATION
LIST,TUPLES AND DICTIONARY
3.
INTRODUCTION
Python isa general-purpose interpreted, interactive,
object-oriented, and high-level programming
language.
It was created by Guido van Rossum during 1985- 1990
4.
Why to LearnPython?
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 ofinstructions 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 TwoNumbers:
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
FUNCTIONS
Block oforganized, 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 additionof 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 avalue 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 whichcan 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
STRINGS AND STRINGMANIPULATION
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
Lists
List isan 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
Tuple:
A tupleis 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