UNIT 1 PPT
UNIT 1 PPT
Programming 07 Hrs
• General problem solving concepts :
1
Prof. S. S. Ayare
What is problem?
2
Prof. S. S. Ayare
What is
PAID?
A logical problem solving process can be done through some steps called
"PAID"
• Problem Statement
3
Prof. S. S. Ayare
Example problem in daily life
Mechanics repair a
broken car Workers goes to work
Problem?
4
Prof. S. S. Ayare
How to solve
the problem?
5
Prof. S. S. Ayare
Strategies
Ask questions!
What do I know about the problem?
What is the information that I have to process in order the
find the solution?
What does the solution look like?
What sort of special cases exist?
How will I recognize that I have found
the solution?
6
Prof. S. S. Ayare
Problem Solving Definition
7
Prof. S. S. Ayare
Problem Solving Definition
8
Prof. S. S. Ayare
Problem Solving in Everyday
Life
There are six step in problem solving:
9
Prof. S. S. Ayare
Problem Solving in Everyday
Life
Can I skip
the step?
10
Prof. S. S. Ayare
Example
problems…
Baking a cake according to certain specifications, input available are the
ingredients (such as eggs, flour, milk …etc.), then followed by activities
or procedures that should be done sequentially, taking into
consideration that any mistake happens by doing any procedure before
the other, results in an unsuitable and undesirable cake.
List
instructions
Understand Evaluate
Identify the Identify Select the that enable
the the
problem alternative best way you to
problem solution
solve the
problem
11
Prof. S. S. Ayare
Problem Solving with Computers
12
Prof. S. S. Ayare
Difficulties with Problem Solving
Lack of
Inadequate Incorrect Alternatives Incorrect
problem
solution problem chosen solution Invalid logic
solving
steps definition incorrectly evaluation
experience
13
Prof. S. S. Ayare
Group Activities
14
Prof. S. S. Ayare
Problem Solving with Computer
15
Prof. S. S. Ayare
Top-Down Design
Top-Down Design
Problem-solving technique in which the problem is divided into
Subproblems; the process is applied to each subproblem.
Modules
Self-contained collection of steps, that solve a problem or subproblem.
Abstract Step
An algorithmic step containing unspecified details.
Concrete Step
An algorithm step in which all details are specified
16
Prof. S. S. Ayare
A General Example
Planning a large party
20
Prof. S. S. Ayare
What is Python?
•Python is a general purpose interpreted interactive object oriented and
high level programming language.
•It was first introducedin 1991 by Guido vanRossum , a
21
Prof. S. S. Ayare
contd..
•Python is multi-paradigm programming language ,which allows user to
open source.
•Python is
widely used for scripting in menu applications
effectively. Game
22
Prof. S. S. Ayare
History of Python
•Python is created by Guido Van Rossum in the 1980s.
•Rossum published the first version of Python code (0.9.0) in February 1991 at the CWI (Centrum
Wiskunde & Informatics) in the Netherlands , Amsterdam.
•Python is derived from ABC programming language, which is a general-purpose programming
language that had been developed at the CWI.
•Rossum chose the name "Python", since he was a big fan of Monty Python's Flying Circus.
•Python is now maintained by a core development team at the institute,
although Rossum still holds a vital role in directing its progress.
23
Prof. S. S. Ayare
Why do people use
Python…?
The following primary factors cited by Python users seem to be these:
Pythonis object-oriented Structure supports such concepts as
polymorphism, operation overloading, and multiple inheritance.
Indentation is one of the greatest future in Python.
It's free (open source)
Downloading and installing Python is free and easy Source code is easily
accessible
24
Prof. S. S. Ayare
It's powerful
-Dynamic typing
-Built-in types and tools
-Library utilities
-Third party utilities (e.g. Numeric, NumPy, SciPy)
-Automatic memory management
It's portable
-Python runs virtually every major platform used today
-As long as you have a compatible Python interpreter installed,
Pythonprograms willrun in exactly the same manner, irrespective
of platform.
25
Prof. S. S. Ayare
Python
Release dates for theVersions
major and minor versions:
Python 1.0 - January 1994
Python 1.5 - December 31, 1997
Python 1.6 - September 5, 2000
Python 2.0 - October 16, 2000
Python 2.1 - April 17, 2001
Python 2.2 - December 21, 2001
Python 2.3 - July 29, 2003
Python 2.4 - November 30, 2004
Python 2.5 - September 19, 2006
Python 2.6 - October 1, 2008
Python 2.7 - July 3, 2010
• To develop the Python program ,click on the File and select NewFile.
• This will open a new text editor where you can write your first program.
# Prints the words Hello Python
print(“Hello Python”)
print(“Its nice learning Python”)
print(“Python is easy to learn”)
30
Prof. S. S. Ayare
Data types in Python
Every value in Python has a datatype. Since everything is an object in Python
programming, data types are actually classes and variables are instance
(object) of these classes.
There are various data types in Python. Some of the important types are
listed below.
•Numbers
Integers, floating point numbers and complex numbers falls under Python
numbers category. They are defined as int, float and complex class in Python.
We can use the type() function to know which class a variable or a value
belongs to and the isinstance() function to check if an object belongs to
a particular class.
31
Prof. S. S. Ayare
Example
>>>a = 5
>>>a = 2.0
>>>a = 1+2j
32
Prof. S. S. Ayare
Datatype: Python List
List is an ordered sequence of items. It is one of the most used
datatype in Python and is very flexible. All the items in a list do not need
to be of the same type.
from a list.
# a[2] = ?
# a[0:3] = ?
# a[5:] =
34
Prof. S. S. Ayare
Datatype: Python
Tuple is an ordered Tuple
sequence of items same as list.
The only difference is that tuples are immutable. Tuples
once created
cannot be modified.
Tuples are used to write-protect data and are usually faster than list as it
its value. 35
Prof. S. S. Ayare
Example
t = (5,'program', 1+3j)
# t[1] = ?
# t[0:3] = ?
36
Prof. S. S. Ayare
Datatype: Python Strings
String is sequence of Unicode characters. We can use single quotes or
double quotes to represent strings. Multi-line strings can be denoted
using triple quotes, ''' or """.
Like list and tuple, slicing operator [ ] can be used with string. Strings
are immutable.
37
Prof. S. S. Ayare
Example
s = 'Hello world!’
# s[4] = ?
print("s[4] = ", s[4])
# s[6:11] = ?
s[5] =?
38
Prof. S. S. Ayare
39
Prof. S. S. Ayare