Introduction
Introduction
OBJECTIVES:
P
To understand the basics of algorithmic problem solving.
S
To learn to solve problems using Python conditionals and loops.
P To define Python functions and use function calls to solve problems.
P To use Python data structures - lists, tuples, dictionaries to represent
U complex data.
N To do input/output with files in Python.
I
T
-I
ARASU ENGINEERING COLLEGE
Department of CSE
UNIT I ALGORITHMIC PROBLEM SOLVING 9
P
Fundamentals of Computing – Identification of Computational Problems
S
Algorithms, building blocks of algorithms (statements, state, control
P flow,functions), notation (pseudo code, flow chart, programming language),
P algorithmic problem solving, simple strategies for developing algorithms
U (iteration, recursion). Illustrative problems: find minimum in a list, insert a card
N in a list of sorted cards, guess an integer number in a range, Towers of Hanoi.
I UNIT II DATA, EXPRESSIONS, STATEMENTS 9
T Python interpreter and interactive mode; values and types: int, float, boolean,
string, and list; variables, expressions, statements, tuple assignment, precedence of
-I
operators, comments; modules and functions, function definition and use, flow of
execution, parameters and arguments; Illustrative programs: exchange the values
of two variables, circulate the values of n variables, distance between two points.
ARASU ENGINEERING COLLEGE
Department of CSE
TEXT BOOKS:
P
Allen B. Downey, ``Think Python: How to Think Like a Computer Scientist’’, 2 nd
S
edition, Updated for Python 3, Shroff/O’Reilly Publishers, 2016 (
P http://greenteapress.com/wp/think- python/)
P Guido van Rossum and Fred L. Drake Jr, “An Introduction to Python – Revised and
U updated for Python 3.2, Network Theory Ltd., 2011.
N
I
T
-I
Introduction ARASU ENGINEERING COLLEGE
Department of CSE
S
# Script Begins
P
A=input(“Enter a message”)
P
print(A)
U # Scripts Ends
N
I Output:
T Welcome to python
-I
Algorithm ARASU ENGINEERING COLLEGE
Department of CSE
S
• The development of an algorithm is a key step in solving a problem. Once we
P have an algorithm, we can translate it into a computer program in some
P programming languages.
U
N • The algorithm development process consists of five major steps.
I Step 1: Obtain a description of the problem.
T Step 2: Analyze the problem.
-I Step 3: Develop a high-level algorithm.
Step 4: Refine the algorithm by adding more detail.
Step 5: Review the algorithm.
Advantages and Disadvantages ARASU ENGINEERING COLLEGE
Department of CSE
P Advantages:
• Easy to understand
S
• Provides definite solution
P
• Independent of programming languages
P
• Easy to debug
U
Disadvantages:
N • Hard to design a logical problem
I • Need more knowledge to create a program
T • Difficult to represent branching and looping statements
-I • Take more time to convert as a program