4. What is a Computer
• It is electronic machine.
• Data is collection of raw facts or figure
• Information
• Knowledge
• Instructions
• Program
• Software
• Hardware
7. History of Computer
• First Generation(1942-1955)
• Second Generation(1955-1964)
• Third Generation(1964-1975)
• Fourth Generation(1975-1989)
8. Performs computations and makes logical decisions
Millions / billions times faster than human beings
Computer programs
Sets of instructions for which computer processes data
Hardware.
Physical devices of computer system.
Software.
Programs that run on computers .
9. What is Computer Science ?
• It will help you understand that the goal of a
computer scientist is to solve problems using
computers.
• You will see how problems are formulated by
means of algorithms and how the process of
abstraction can be used to break problems
down to easily manageable pieces.
•
18 Jan 2020 9
10. What is Computer Science ?
Computers are used just about everywhere in our
society:
Communications: internet, e-mail, cell phones
Word Processing: typing/printing documents
Business Applications: Accounting, spreadsheets
Entertainment: Games, Multimedia Applications
Database Management: Police Records, Stock Market
Engineering Applications: Scientific Analysis,
simulations
Manufacturing: CAD/CAM, Robotics, Assembly
18 Jan 2020 10
11. • A computer is a programmable machine that
receives input, stores and manipulates data,
and provides output in a useful format.
12.
13. Software itself can be broken down into 3 main
categories
• System Software: is designed to operate the computer’s hardware and to
provide and maintain a platform for running applications. (e.g., Windows,
MacOS, Linux, Unix, etc..)
• Middleware: is a set of services that allows multiple processes running on
one or more machines to interact.
• Most often used to support and simplify complex distributed applications.
It can also allow data contained in one database to be accessed through
another.
• Middleware is sometimes called plumbing because it connects two
applications and passes data between them. (e.g., web servers,
application servers).
18 Jan 2020 13
14. • Application Software: is designed to help the user perform
one or more related specific tasks. Depending on the work
for which it was designed, an application can manipulate
text, numbers, graphics, or a combination of these
elements. (e.g., office suites, web browsers, video games)
• Computer science is the study of the theoretical
foundations of information and computation, and of
practical techniques for their implementation and
application in computer systems (Wikipedia)., media
players, etc…)
• A program is a sequence of instructions that can be
executed by a computer to solve some problem or
perform a specified task
18 Jan 2020 14
15. • A programming language is an artificial
language designed to automate the task of
organizing and manipulating information,
and to express problem solutions precisely.
18 Jan 2020 15
16. • A programming language “boils down to” a set of words, rules
and tools that are used to explain (or define) what you are
trying to accomplish.
• There are many different programming languages just as
there are many different "spoken" languages.
• Traditional programming languages were known as structural
programming languages (e.g., C, Fortran, Pascal, Cobol, Basic).
• Since the late 80's however, object-oriented programming
languages have become more popular (e.g., JAVA, C++, C#)
18 Jan 2020 16
17. Problem Solving, Programming and
Python Programming
Lectures: 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.
18. 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.
19. 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).
22. 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?
23. 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.
24. Problem Solving Definition
• A Systematic approach to defining problem
and creating a vast number of possible
solutions without which will gives maximum
accuracy.
25. Problem Solving in Everyday Life
• There are six step in problem solving:
26. Problem Solving in Everyday Life
• Can I
skip
the
step?
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
27. 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.
28. Problem Solving with Computers
• Definitions by Sprankle & Hubbard (2012):
SOLUTION
instructions
followed to
produce best
result
RESULT
Outcome OR
completed
computer-
assisted answer
PROGRAM
Set of
instructions for
solution using
computer
language
30. 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.
31. 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
33. Top-Down Design
• Top-Down Design
• Problem-solving technique in which the problem is divided
into
• Sub problems; the process is applied to each sub problem.
• Modules
• Self-contained collection of steps, that solve a problem or
sub problem.
• Abstract Step
• An algorithmic step containing unspecified details.
• Concrete Step
• An algorithm step in which all details are specified
35. Top Down Vs Bottom Up
• Generation of test cases • Allows information
hiding asit fristb
36. Control Structure Used in Algorithm
• An algorithm has finite no of step and some
step may involved decision making decision .
•
Sequence
Decision
Repetition
37. • Sequential: default mode. Sequential execution of code statements
(one line after another) -- like following a recipe
• Selection: used for decisions, branching -- choosing between 2 or
more alternative paths. In C++, these are the types of selection
statements:
– if
– if/else
– switch
• Repetition: used for looping, i.e. repeating a piece of code multiple
times in a row. In C++, there are three types of loops:
– while
– do/while
– for
Sequence
38.
39.
40. 4 ALGORITHMIC PROBLEM SOLVING
STEPS
• Understanding the problem
• 2. Determining the capabilities of the
computational device
• 3. Exact/approximate solution
• 4. Select the appropriate data structure
• 5. Algorithm design techniques
• 6. Methods of specifying an algorithm
• 7. Proving an algorithms correctness
• 8. Analysing the performance of an algorithm
41. Understanding the problem
• Understanding the problem The problem
given should be clearly and completely
understood.
• It is compared with earlier problems that
have already been solved to check if it is
similar to them and a known algorithm exists.
If the algorithm is available, it is used
otherwise a new one has to be developed.
42. • Determining the capabilities of the
computational device After understanding the
problem, the capabilities of the computing
device should be known. For this, the type of
the architecture, speed and memory
availability of the device are noted.
43. Exact/approximate solution
• The next step is to develop the algorithm. The
algorithm must compute correct output for all
possible and legitimate inputs.
• This solution can be an exact solution or an
approximate solution.
• For example, you can only have an
approximate solution in case of finding square
root of number or finding the solutions of
nonlinear equations
44. • Select the appropriate data structure A data
type is a well-defined collection of data with a
well defined set of operations on it.
• A data structure is basically a group of data
elements that are put together under one
name, and which defines a particular way of
storing and organizing data in a computer so
that it can be used efficiently.
• The elementary data structures are as follows.
45. SIMPLE STRATEGIES AND NOTATIONS
FOR DEVELOPING ALGORITHMS
• An algorithm is a step–by–step procedure for solving a
task or problem.
• Unambiguous and finite in number.
• Basically, an algorithm is nothing but English-like
representation of logic which is used to solve the
problem.
• For accomplishing a particular task, different
algorithms can be written.
• The different algorithms differ in their requirements of
CPU time and memory space.
• The programmer selects the best suited algorithm for
the given task to be solved
46. Control Structures Used in Algorithms
• An algorithm has a finite number of steps and
some steps may involve decision making and
repetition. Broadly speaking, an algorithm
may employ three control structures, namely,
sequence, decision, and repetition
47. Algorithm to add two numbers
• Step 1 : Start
• Step 2 : Input first number as A
• Step 3 : Input second number as B
• Step 4 : Set Sum = A + B
• Step 5 : Print Sum
• Step 6 : End
48. Decision statements
• are used when the outcome of the process
depends on some condition.
• For example,
• if x = y, then print “EQUAL”.
• Hence, the general form of the if construct can be
given as follows:
• IF condition
– then
• process
49. • A decision statement can also be stated in the
following manner:
• IF condition
–then process1
ELSE
–process2
50. Algorithm to test the quality of two
numbers
• Step 1 : Start
• Step 2 : Input first number as A
• Step 3 : Input second number as B
• Step 4 : IF A = B Print "Equal" ELSE Print "Not
equal" [END of IF]
• Step 5 : End
51. Algorithm to find the greatest of three
numbers
• Step 1: Start
• Step 2: Read the three numbers A,B,C
52. Algorithm to find the greatest of three numbers
using an additional variable MAX
53.
54.
55.
56.
57.
58. 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.
59. What is Python?
• Python is a general purpose interpreted interactive
object oriented and high level programming language.
• It was first introduced in 1991 by Guido van Rossum , a
Dutch computer programmer.
• The language places strong emphasis on code reliability
and simplicity so that the programmers can develop
applications rapidly
60. • 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 Game menu applications
effectively.
61. 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.
62. Why do people use Python…?
• The following primary factors cited by Python users seem to be
these:
• Python is 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
63. • 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,
• Python programs will run in exactly the same manner, irrespective of platform.
64. Python Versions
Release dates for the 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
65.
66.
67. 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
68. • Source code extension is .py
• Byte code extension is .pyc (compiled python
code)
69. 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”)
70. 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.
• Python 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.
72. 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.
74. Datatype: Python Tuple
Tuple is an ordered 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.
76. 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.
77. 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] =?