More Related Content
Similar to Input, Processing and Output (20)
More from Munazza-Mah-Jabeen (20)
Input, Processing and Output
- 1. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
• Python is a simple, easy to learn, powerful, high
level and object-oriented programming language.
• Python is an interpreted scripting language also.
Guido Van Rossum is known as the founder of
python programming.
• Python is a general purpose, dynamic, high level and
interpreted programming language.
• It supports Object Oriented programming approach
to develop applications.
Introduction to Python:
- 2. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
…
• It is simple and easy to learn and provides lots of high-
level data structures.
• Python is easy to learn yet powerful and versatile
scripting language which makes it attractive for
Application Development. Python's syntax and dynamic
typing with its interpreted nature, makes it an ideal
language for scripting and rapid application
development.
• Python supports multiple programming pattern,
including object oriented, imperative and functional or
procedural programming styles.
- 3. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
• Python is not intended to work on special area such
as web programming. That is why it is known as
multipurpose because it can be used with web,
enterprise, 3D CAD etc.
• We don't need to use data types to declare variable
because it is dynamically typed so we can write
a=10 to assign an integer value in an integer
variable.
• Python makes the development and debugging fast
because there is no compilation step included in
python development and edit-test-debug cycle is
very fast.
- 4. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Python Features
• Easy to Learn and Use
• Python is easy to learn and use. It is developer-friendly and high
level programming language.
• Expressive Language
• Python language is more expressive means that it is more
understandable and readable.
• Interpreted Language
• Python is an interpreted language i.e. interpreter executes the code
line by line at a time. This makes debugging easy and thus suitable
for beginners.
• Cross-platform Language
• Python can run equally on different platforms such as Windows,
Linux, Unix and Macintosh etc. So, we can say that Python is a
portable language.
- 5. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
• Free and Open Source
• Python language is freely available at official web address. The
source-code is also available. Therefore it is open source.
• Object-Oriented Language
• Python supports object oriented language and concepts of classes
and objects come into existence.
• Extensible
• It implies that other languages such as C/C++ can be used to
compile the code and thus it can be used further in our python code.
• Large Standard Library
• Python has a large and broad library and provides rich set of module
and functions for rapid application development.
• GUI Programming Support
• Graphical user interfaces can be developed using Python.
• Integrated
• It can be easily integrated with languages like C, C++, JAVA etc.
- 6. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Python History
• Python laid its foundation in the late 1980s. The implementation of
Python was started in the December 1989 by Guido Van Rossum at
CWI (Centrum Wiskunde & Informatica) in Netherland.
• In February 1991, van Rossum published the code (labeled version
0.9.0) to alternate sources.
• In 1994, Python 1.0 was released with new features like: lambda,
map, filter, and reduce.
• Python 2.0 added new features like: list comprehensions, garbage
collection system.
• On December 3, 2008, Python 3.0 (also called "Py3K") was released.
It was designed to rectify fundamental flaw of the language.
• ABC programming language is said to be the predecessor of Python
language which was capable of Exception Handling and interfacing
with Amoeba Operating
- 7. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Python Version
- 8. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Python Application Area
• Web Applications
• Desktop GUI Applications
• Software Development
• Scientific and Numeric
• Business Applications
• Console Based Application
• Audio or Video based Applications
• 3D CAD Applications
• Enterprise Applications
• Applications for Images
- 9. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Python Keywords
- 10. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Input – Processing - Output
- 11. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Designing a Program
1. The first step in programming is designing –
flowcharts and pseudocode help with this
process.
2. Next, the code is written.
3. All code must be cleared of all syntax errors.
4. After the executable is created, it can be
checked for logic errors.
5. If logic errors exist, the program must be
debugged.
- 12. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
…
The purpose of Programming Logic and
Design is to focus on Flowcharts and
Pseudocode.
The design is the foundation of a good
program.
Figure 2-1 The program development cycle
- 13. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Two steps in designing a program
1. Understand the tasks that the program is to
perform.
• Learning what the customer wants.
2. Determine the steps that must be taken to
perform the task.
• Create an algorithm, or step-by-step directions to
solve the problem.
• Use flowcharts and/or pseudocode to solve.
- 14. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Pseudocode:
• Fake code used as a model for programs
• No syntax rules
• Well written pseudocode can be easily translated
to actual code
Display Hello World
Print(“Hello World!”)
- 15. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Flowcharts
• A diagram that graphically
depicts the steps that take
place in a program
Terminator used for
start and stop
Parallelogram used
for input and output
Rectangle used for
processes
Figure 2.2 Flowchart for the
pay calculating program
- 16. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Output, Input, and Variables
Output – data that is generated and displayed
Input – data that a program receives
Variables – storage locations in memory for data
Computer programs typically follow 3 steps
1. Input is received
2. Some process is performed on the input
3. Output is produced
- 17. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Variable Naming Convention
Programmers can define variable names following
certain rules
– Must be one word, no spaces
– Generally, punctuation characters are avoided
– Generally, the first character cannot be a number
– Name a variable something that indicates what may
be stored in it camel Case is popular naming
convention.
- 18. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Variable Assignment & Calculations
Calculations are performed using math operators
The expression is normally stored in variables
Set sale = price – discount
Table 2-1 Common math operators
- 19. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Variable Declarations & Data Types
A variable declaration includes a variable’s name
and a variable’s data type
Data Type – defines the type of data you intend to
store in a variable
– Integer – stores only whole numbers
– Real – stores whole or decimal numbers
– String – any series of characters
- 20. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1-20
Documenting a Program
External documentation describes aspects of the
program for the user, sometimes written by a
technical writer
Internal documentation explains how parts of the
program works for the programmer, also
known as comments
// comments are often distinguished within
// the program with line comments
- 21. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Designing Your First Program
Calculate the batting average for any player
Batting Average = Hits ÷ Times at Bat
Determine what is required for each phase of the
program:
1.What must be read as input?
2.What will be done with the input?
3.What will be the output?
- 22. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Designing Your First Program
1. Input is received.
– The number of hits
– The number of times at bat
2. Some process is performed on the input.
– Calculate the batting average
– Divide the number of hits by the number of times at
bat
3. Output is produced.
– The player’s batting average
- 23. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Designing Your First Program
Figure 2-17 Flowchart for program 2-15
- 24. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Designing Your First Program
Summary
– Input
• Determine data needed for input
• Choose variables to store the input
– Process
• Determine calculations to be performed
• Choose variables to store the calculations
– Output
• Determine what output the program will display
• Usually the results of the program’s calculations