Professional Documents
Culture Documents
Python Programming: Reema Thareja
Python Programming: Reema Thareja
Python Programming: Reema Thareja
Python Programming
Using Problem Solving Approach
Reema Thareja
Hardware Technology: Manufactured using Large Scale and Very Large Scale integrated circuits.
Software Technology: Programming was done in high level language.
Used for: Scientific, commercial, interactive and network applications
Examples: IBM PC, Apple II, TRS-80, VAX 9000, CRAY-1, CRAY-2, CRAY-X/MP
Highlights: Faster, smaller, cheaper, powerful, reliable, and easier to use than the previous generation computers
12
13
15
16
18
An input device is used to feed data and instructions into the computer.
Some of the input devices that are widely used by computer users to feed data or instruction to the computer are
keyboard, mouse, trackball, joystick, stylus, touch screen, barcode reader, optical character recognition (OCR) device,
optical mark recognition (OMR), MICR, web and digital cameras, etc.
19
• Distribution of a hard copy is not only costly but also slower. © OXFORD UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED.
Memory
21
22
23
© OXFORD UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED.
Primary Memory - ROM
ROM is non-volatile, that is, the data is retained in it even when the computer is turned off.
Rewritable ROM chips include PROMs, EPROMs, and EEPROMs.
• Programmable read-only memory (PROM) also called one-time programmable ROM can be written to or
programmed using a special device called a PROM programmer. The working of a PROM is similar to that of a
CD-ROM recorder which enables the users to write programs just once but the recorded data can be read
burning
multiple times. Programming a PROM is also called .
• Erasable programmable read-only memory (EPROM) is a type of ROM that can be erased and re-programmed.
The EPROM can be erased by exposing the chip to strong ultraviolet light typically for 10 minutes or longer and
then rewritten with a process that again needs higher than usual voltage applied.
• Electrically erasable programmable read-only memory (EEPROM) allows its entire or selected contents to be
electrically erased, then rewritten electrically. The process of writing an EEPROM is also known asflashing . 24
• Driver software
• Educational software
• Media players and media development software
• Productivity software
• Operating systems software
• Computer games
• Application software
• System software
25
26
27
29
31
In the design phase, a plan of actions is made before the actual development process can start.
In implementation phase, the designed algorithms are converted into program code using any of
the high-level languages.
During testing, all the modules are tested together to ensure that the overall system works well as
a whole product.
In software deployment, training, and support phase, the software is installed or deployed in the
production environment.
Maintenance and enhancements are ongoing activities that are done to cope with newly
discovered problems or new requirements
32
34
Step 1: Input first number as A Step 1: Input first number as A Step 1: Input number as A
Step 2: Input first number as B Step 2: Input first number as B Step 2: IF A % 2
Step 3: Set temp = A Step 3: IF A > B Print “Even”
Step 4: Set A = B Print A ELSE
Step 5: Set B = temp ELSE IF A < B Print “Odd”
Step 6: Print A, B Print B [END OF IF]
Step 7: End ELSE Step 3: End
Print “Numbers are equal”
[END OF IF]
Step 4: End
35
Control Structures Used in Algorithms
Write an Algorithm to print Write an Algorithm to find the sum
Step 1: Enter the marks obtained as
grade obtained by the student. M of first N natural numbers.
Marks Grade Step 2: IF M > 75
Above 75 O
Print “O”
Step 3: IF M >= 60 and M < 75 Step 1: Input N
60 – 75 A
Print “A” Step 2: Set I = 1, sum = 0
50 – 60 B
Step 4: IF M >= 50 and M < 60 Step 3: Repeat Steps 4 and 5 while I <
40 – 50 C
Print “B” N
Less than 40 D Step 5: IF M >= 40 and M < 50 Step 4: Set sum = sum + 1
Print “C” [END OF LOOP]
ELSE Step 5: Print sum
Print “D” Step 6: End
[END OF IF]
Step 6: End
36
Control Structures Used in Algorithms
Write a recursive algorithm to find the factorial of a number.
37
Flowcharts
A flowchart is a graphical or symbolic representation of a process. It is basically used to design and document
virtually complex processes to help the viewers to visualize the logic of the process.
Example: Draw a flowchart to calculate the sum of the first
10 natural numbers.
38
39
Example: Write a pseudocode for calculating the price of a product after adding the sales tax to its original
price.
40
Solution:
1. Read hours worked
2. Read wages per hour
3. Set overtime charges to 0
4. Set overtime hrs to 0
5. IF hours worked > 30 then
a. Calculate overtime hrs = hours worked – 30
b. Calculate overtime charges = overtime hrs x ( 2 x wages per hour)
c. Set hours worked = hours worked – overtime hrs
ENDIF
1. Calculate salary = (hours worked x wages per hour) + overtime charges
2. Display salary
3. End 41
Variables: hours worked, wages per hour, overtime charges, overtime hrs,
salary
Types of Errors
Run-time errors occur when the program is being run executed. Such errors occur when the program performs
some illegal operations like dividing a number by zero, opening a file that already exists, lack of free memory space,
finding square or logarithm of negative numbers. Run-time errors may terminate program execution.
Syntax Errors are generated when rules of a programming language are violated. Python interprets (executes) each
instruction in the program line by line. The moment interpreter encounters a syntactic error, it stops further
execution of the program.
Semantic or Logical Errors are those errors which may comply with rules of the programming language but gives an
unexpected and undesirable output which is obviously not correct. For example, if you write a program to add two
numbers but instead of writing ‘+’ symbol, you put the ‘-’ symbol.
Linker Errors These errors occur when the linker is not able to find the function definition for a given prototype.
42
© OXFORD UNIVERSITY PRESS 2017. ALL RIGHTS RESERVED.
Testing
Unit Tests: Unit testing is applied only on a single unit or module to ensure whether it exhibits the expected
behavior.
Integration Tests: These tests are a logical extension of unit tests. In this test, two units that have already been
tested are combined into a component and the interface between them is tested.
System Tests: System testing checks the entire system.
43
44