0% found this document useful (0 votes)
10 views

UNIT 1 PPT

The document outlines an introductory course on problem solving, programming, and Python, covering general problem-solving concepts, strategies, and the basics of Python programming. It discusses methodologies for problem-solving, including top-down design and object-oriented design, as well as the history and features of Python. Additionally, it provides examples of data types in Python, such as lists, tuples, and strings, along with their usage.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

UNIT 1 PPT

The document outlines an introductory course on problem solving, programming, and Python, covering general problem-solving concepts, strategies, and the basics of Python programming. It discusses methodologies for problem-solving, including top-down design and object-oriented design, as well as the history and features of Python. Additionally, it provides examples of data types in Python, such as lists, tuples, and strings, along with their usage.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

UNIT: I Problem Solving, Programming and Python Lectures:

Programming 07 Hrs
• General problem solving concepts :

• Problem solving in everyday life,

• types of problems, problem solving with computers,

• difficulties with problem solving

• problem solving aspects, top down design. Problem Solving Strategies

• Program Design Tools: Algorithms, Flowcharts and Pseudo-codes, implementation of


algorithms.
• Basics of Python Programming: Features of Python, History and Future of Python,
Writing and executing Python program, Literal constants, variables and identifiers,
Data Types, Input operation, Comments, Reserved words, Indentation, Operators and
expressions, Expressions in Python.

1
Prof. S. S. Ayare
What is problem?

The problem is defined as the objective or the specific output that we


want to attain; through a sequence of steps and activities and, specific
input.

2
Prof. S. S. Ayare
What is
PAID?
A logical problem solving process can be done through some steps called

"PAID"

• Problem Statement

• Analyze the problem in detail

• Identify likely causes

• Define actual cause(s)

3
Prof. S. S. Ayare
Example problem in daily life

Students do science experiment

Mechanics repair a
broken car Workers goes to work

Problem?

Doctors find new bacteria Kids want eat sweets

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

A Systematic approach to defining problem(question or situation that presents


uncertainty or difficulty) and creating a vast number of possible solutions without

judging these solutions.

7
Prof. S. S. Ayare
Problem Solving Definition

A Systematic approach to defining problem and creating a vast number of possible

solutions without which will gives maximum accuracy.

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?

According to Sprankle and


Hubbard (2012), if the six
step not completed well, the
result may be less than
desired

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

Definitions by Sprankle & Hubbard (2012):

SOLUTION RESULT PROGRAM


Set of
instructions Outcome OR
instructions
followed to completed
for solution
produce best computer-
using
result assisted answer
computer
language

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

In in group of 4 persons, think a problems in your daily life at


home, office, park, school, shopping mall or wherever your go.
Please explain how you solve the problem using the six steps of
problem solving.

14
Prof. S. S. Ayare
Problem Solving with Computer

Two methodologies used to develop computer


solutions to a problem
– Top-down design focuses on the tasks to be done
– Object-oriented design focuses on the data involved in the
solution
But first, let's look at a way to express algorithms:
pseudo code

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

Subdividing the party


planning
17
Prof. S. S. Ayare
18
Prof. S. S. Ayare
19
Prof. S. S. Ayare
Programming basics
• code or source code: The sequence of instructions in a program.
• syntax: The set of legal structures and commands that can be used in a particular
programming language.
• output: The messages printed to the user by a program.
• console: The text box onto which output is printed.
– Some source code editors pop up the console as an external window, and
others contain their own console window.

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

Dutch computer programmer.

•The language places strong emphasis on code reliability and simplicity

so that the programmers can develop applications rapidly

21
Prof. S. S. Ayare
contd..
•Python is multi-paradigm programming language ,which allows user to

code in several different programming styles.

• Python supports cross platform development and is available through

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

Release dates for the major and minor versions:


Python 3.0 - December 3, 2008
Python 3.1 - June 27, 2009
Python 3.2 - February 20, 2011
Python 3.3 - September 29, 2012
Python 3.4 - March 16, 2014
Python 3.5 - September 13, 2015
26
Prof. S. S. Ayare
27
Prof. S. S. Ayare
28
Prof. S. S. Ayare
Python Code Execution
Python’s traditional runtime execution model: source code you type is
translated to byte code, which is then run by the Python Virtual
Machine. Your code is automatically compiled, but then it is interpreted.

Source code extension is .py


Byte code extension is .pyc (compiled python code)
29
Prof. S. S. Ayare
Your First Program

• 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

print(a, "is of type", type(a))

>>>a = 2.0

print(a, "is of type", type(a))

>>>a = 1+2j

print(a, "is complex number?", isinstance(1+2j,complex))

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.

Declaring a list is pretty straight forward. Items separated by commas


are enclosed within brackets [ ].

>>> a = [1, 2.2, 'python']


We can use the slicing operator [ ] to extract an item or a range of items

from a list.

Index starts form 0 in Python.


33
Prof. S. S. Ayare
Example
a = [5,10,15,20,25,30,35,40]

# a[2] = ?

print("a[2] = ", a[2])

# a[0:3] = ?

print("a[0:3] = ", a[0:3])

# a[5:] =

print("a[5:] = ", 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

cannot change dynamically.

It is defined within parentheses () where items are separated by commas.

>>> t = (5,'program', 1+3j)


We can use the slicing operator [] to extract items but we cannot change

its value. 35
Prof. S. S. Ayare
Example
t = (5,'program', 1+3j)

# t[1] = ?

print("t[1] = ", t[1])

# t[0:3] = ?

print("t[0:3] = ", t[0:3])


# Generates error
# Tuples are immutablet[0] = 10

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 """.

>>> s = "This is a string"


>>> s = '''a multiline

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] = ?

print("s[6:11] = ", s[6:11])


# Generates error
# Strings are immutable in Python

s[5] =?

38
Prof. S. S. Ayare
39
Prof. S. S. Ayare

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy