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

Topic 1 - Introduction

Uploaded by

babi.labi04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Topic 1 - Introduction

Uploaded by

babi.labi04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 54

Introduction to programming with Python

Topic 1:
Introduction

© NCC Education Limited


Introduction -Topic 1 - 1.2

Why Study Programming?


• The skill of problem solving is needed in all
aspects of life.
• Programming helps you to build problem solving
skills. You will learn how to take a problem and
structure an answer that solves the problem.
• Programming also gives you an understanding
of how computer programs work, which can help
you to develop your own programs and
understand how to correct errors if they occur.
Introduction -Topic 1 - 1.3

The Unit Roadmap


• Lesson 1 - Introduction
• Lesson 2 - Getting Started with Python
• Lesson 3 - Introduction to data types and sequential programming
• Lesson 4 - Making decisions: selection statements
• Lesson 5 - Performing repetitive tasks: Loops
• Lesson 6 - Dealing with Errors
• Lesson 7 - Programming with Strings
• Lesson 8 - List
• Lesson 9 - Modularity
• Lesson 10 - Object Oriented Programming
• Lesson 11 - Storing Data in Files
• Lesson 12 - Summary and Assignment preparation
Introduction -Topic 1 - 1.4

What Is This Lesson About?


• In this lesson you will learn about how digital
computers run programs through the use of
instructions.
• We will look at different types of programming
language and how programs are developed
using a system development lifecycle.
• You will then learn how programs are designed
using algorithms and how they are tested
through test plans.
Introduction -Topic 1 - 1.5

Scope and Coverage


This topic will cover:
• Digital computers: giving instructions
• Computer languages: low level, high level; types of
languages; why Python??
• Software development lifecycle
• Developing quality software: Software Engineering
Principles
• Designing programs: Algorithms, Pseudocode, sequence,
selection, iteration
• Test plans
Introduction -Topic 1 - 1.6

Learning Outcomes

By the end of this topic students will be able to:


• Identify how computers are given instructions
• Describe the difference between and characteristics of low
level and high-level languages
• Describe the stages of the software development lifecycle
• Identify Software Engineering Principles
• Identify the tools used to design programs
• Create and use a test plan
Introduction -Topic 1 - 1.7

Instructions - Activity

• Follow these instructions:


– Write down the number 10
– Add the number 20
– Multiply by 100
– Subtract 30
– Say the answer out loud
Introduction -Topic 1 - 1.8

Instructions

• You just ran a set of instructions.


• You took each instruction one at a time and
executed it.
Task:
Work with a partner to generate a list of instructions
for another set of students to execute. This could be
mathematical, or action based (for example
movements).
Introduction -Topic 1 - 1.9

Digital Computers - Instructions

• Digital computers follow instructions.


• Digital means it uses 1s and 0s (binary).
• Humans write programs for computers that use a
list of instructions.
• Computers execute these instructions one at a
time.
• In the next few slides, we will look at the different
ways these instructions can be written.
Introduction -Topic 1 - 1.10

Low-level Computer Languages

• Low-level means it is at the computer’s level.


• It is written for execution by the computer.
• It is harder for humans to read and write than high-
level, because it is in 1s and 0s or short
commands.
• There are two types of low-level code:
– binary
– assembly language
Introduction -Topic 1 - 1.11

Binary vs Assembly Language


Binary Assembly language
1s and 0s Uses mnemonics
Split into opcode and operand Split into opcode and operand
Opcode is an instruction, operand is a Opcode is and instruction, operand is a
value or address value or address
e.g. e.g.
01101011 11100101 LDD X
00001111 00000001 ADD #1
Can be run direct by the computer Has to be translated into binary using an
assembler
Is machine dependent (it can only run on Is machine dependent (it can only run on
the type of machine it is written for) the type of machine it is written for)
because different machines might have because different machines might have
different instruction sets different instruction sets
Introduction -Topic 1 - 1.12

High-level Language
• High-level means it is at human-level.
• It uses words that are usually in English for
example IF, WHILE, INPUT, OUTPUT.
• It is easier for humans to read and write than low-
level.
• High-level languages need to be translated into
low-level languages before a computer can run
them. This is done using a translator (compiler or
interpreter).
Introduction -Topic 1 - 1.13

Do You Know This?


• There are hundreds of different high-level languages e.g.
Python, Java, C++, VB.NET
• Some languages are more specialised and are best for
specific tasks, for example:
• LISP is focused on artificial intelligence
• JavaScript is for adding functionality to websites
• Use the Internet to find TWO (2) examples of high-level
programming languages that have specific purposes. Find
out what these purposes are and share them with the other
students.
Introduction -Topic 1 - 1.14

Python

• Python is one example of a high-level programming


language.
• It was first designed in 1991 and ‘was mainly developed for
emphasis on code readability’ (Geeks for geeks(2), no
date).
• It is called Python after the TV show Monty Python (not after
the snake!).
• In this unit you will learning how to write computer programs
in Python.
Introduction -Topic 1 - 1.15

Why Python?
• Python is a popular language (especially for learning to program)
because of its readability and intuitiveness
• Compare how these different languages output the same statement and
which is most straight forward.
Langua Program statement
ge
VB.NET Console.writeline("Hello World")

Java System.out.println("Hello World")

C++ Cout << "Hello World“;

Python print("Hello World")


• Python is commonly used to create applications. Visit
https://www.python.org/about/apps/ to explore where Python is used
Introduction -Topic 1 - 1.16

Checkpoint Summary
• Computers execute instructions
• Low-level languages include binary and assembly
• Low-level languages are executed by the computer
• High-level languages are human-friendly
• High-level languages need translating to a low-level
language
• Python is an example of a high-level language
• Python is intuitive and easier to use/write/program
than some other high-level languages
Introduction -Topic 1 - 1.17

https://peterhigginson.co.uk/lmc
Introduction -Topic 1 - 1.18

Software Development Lifecycle

• When a piece of software is being designed there


needs to be a structure to identify what needs to be
done.
• Without a structure, or plan, to follow:
– Some requirements might be missed
– The design might not be distributed to all developers
– People might not know what their role is
– Etc.
Introduction -Topic 1 - 1.19

Software Development Lifecycle


• There are lots of different versions of the software development
lifecycle.
• Some have more stages than others.
• Some go straight into programming and don’t include formal designing.
• Some are iterative, some are linear, and some are cyclic.
• Different lifecycles have different benefits and drawbacks. The one
chosen depends on:
– The program being developed
– The preferences of the developers
– The preferences of the end-user
– The time available
Introduction -Topic 1 - 1.20

Software Development Lifecycle Task

• A software development lifecycle typically has


between 5-7 phases depending on how they are
designed. A 6-phase lifecycle is given below.
• Work with a partner to identify the order that you think these
should be appear in the lifecycle:
• Testing
• Maintenance
• Design
• Analysis
• Implementation (into the end-user's system)
• Programming
Introduction -Topic 1 - 1.21

Software Development Lifecycle


Analysis

Maintenance
Design

Implementation Programming
(development)

Testing
Introduction -Topic 1 - 1.22

Stage 1: Analysis

• The problem is investigated


• What needs to be done?
• Why does it need to be done?
• What data needs to go into the program?
• What happens to the data?
• What needs to be output?
Introduction -Topic 1 - 1.23

Stage 1: Analysis

• This can be done by:


– Interviewing the end user(s) and people who interact
with the system
– Using the current system (if it’s a replacement) to
identify what it does, how it does it, what it is missing
– Observing the end user(s) using the current system
– Sending questionnaires to the end user(s) to find out
what they need
Introduction -Topic 1 - 1.24

Stage 2: Design

• Solutions to the problem are designed


• This could include:
– Identification of success criteria
– Identification of all inputs, processes and outputs
– Structure charts
– Flowcharts
– Pseudocode
– Prototypes
Introduction -Topic 1 - 1.25

Stage 3: Programming

• The design is used to create the program using a


suitable programming language
• The design stage might need to be revisited if there
are problems along the way
• The program will also need to be tested during
development
• At the end of this stage a final program is produced
Introduction -Topic 1 - 1.26

Stage 4: Testing

• This is where the final program is tested to:


– Make sure it works
– Makes sure it is robust (cannot be broken e.g. by invalid
data entry)
– Make sure it meets all success criteria
– The end user is satisfied with the final product
Introduction -Topic 1 - 1.27

Stage 5: Implementation

• The final, working, program is installed and ready


to use
• Depending on the system this might require
additional hardware to be installed for the end user
• The system is tested again in-place to make sure it
is ready to use
Introduction -Topic 1 - 1.28

Stage 6: Maintenance

• All programs need some form of maintenance


– Perfective maintenance:
• The program could be made improved
• It could run faster
• It could have more validation
– Adaptive maintenance:
• A new requirement is created
• The programs needs to be changed to implement this new
requirement
– Corrective maintenance:
• An error is found
• The program needs changing to remove the error
Introduction -Topic 1 - 1.29

Software Development Lifecycle


• This is a cycle because if maintenance is required
the whole process starts again
• The change/improvement/correction is analysed
• … then a solution designed
• … then programmed
• … then tested
• … then implemented
• … and finally, back to any maintenance required
Introduction -Topic 1 - 1.30

Developing Quality Software

• It is important to develop quality software:


– To make sure requirements are met … so the program
does what the end user needs it to do
– To avoid problems or errors in software … some
systems could have significant consequences if there
are errors
Introduction -Topic 1 - 1.31

Did You Know This?

• An update to the London Ambulance IT system


caused the system to fail.
• There was an unknown fault in the software.
• The system did not allow staff to manage
ambulances for several hours.
(Digital Health, 2023)
Introduction -Topic 1 - 1.32

Software Engineering Principles


A set principles can be followed by software engineers to make
sure they are developing quality software.

One example of these principles is given:


1. manage using a phased life-cycle plan.
2. perform continuous validation.
3. maintain disciplined product control.
4. use modern programming practices.
5. maintain clear accountability for results.
6. use better and fewer people.
7. maintain a commitment to improve the process.

(Boehm, B. 1983)
Introduction -Topic 1 - 1.33

Designing Programs

• A program can be designed using different


processes and tools.
• Some of these were given in the design stage of
the system development lifecycle
• In this section we will look at: Algorithms,
Pseudocode, sequence, selection and iteration.
Introduction -Topic 1 - 1.34

Algorithms

• An algorithm is a sequence of steps


• Each step is performed in the order it is written
• You ran an algorithm earlier when you did the instructions
on slide 7

• Algorithms can be presented in lots of different ways:


– Structure English
– Pseudocode
– Flowcharts
Introduction -Topic 1 - 1.35

Pseudocode

• Pseudo means fake, or not real.


• Pseudocode is fake code.
• It looks like program code from a high-level language, but it
isn’t for one specific language.
• A pseudocode algorithm should be understood by any
programmers and be able to be converted into most high-
level programming language.
• There are no set rules for the commands you must use.
• It does have a structure.
Introduction -Topic 1 - 1.36

Pseudocode Structure

• It uses key words. For example: input, output.


• It has variables and other data structures for
example arrays.
• It has selection such as if statements.
• It has iteration such as a for loop.
• Overall, it works the same way as a high-level
language, it is just not fussy about the
commands that are used.
Introduction -Topic 1 - 1.37

Pseudocode Example

Read this pseudocode algorithm:


INPUT number
number = number + number
OUTPUT number
number2 = INPUT
number3 = number2 * number
Print(number3)
Introduction -Topic 1 - 1.38

Pseudocode Example
• The pseudocode
algorithm is not specific
to one language.
INPUT number
• It has variables and number = number + number
assignment. OUTPUT number
number2 = INPUT
• It has input and output. number3 = number2 * number
• A programmer can Print(number3)

convert this to another


language.
Introduction -Topic 1 - 1.39

Pseudocode vs Python vs
VB.NET
INPUT number number = input()
number = number + number number = number + number
OUTPUT number print(number)
number2 = INPUT number2 = input()
number3 = number2 * number number3 = number2 * number
Print(number3) print(number3)

Dim number, number2, number3 As Integer


number = Console.ReadLine()
Console.WriteLine(number)
number2 = Console.ReadLine()
number3 = number2 * number
Console.WriteLine(number3)
Introduction -Topic 1 - 1.40

Sequence
• A sequence is when each instruction is run once,
one after the other, in the order they are written.
• For example:
Stand up
Sit down
Clap your hands
• This is a sequence because first you would stand
up, then you would sit down, then you would clap
your hands.
Introduction -Topic 1 - 1.41

Sequence Activity

• Write a sequence of actions for a partner to


perform.
• Make these physical movements and actions
they can perform.
Introduction -Topic 1 - 1.42

Selection
• Selection has a condition.
• The condition is checked and is either true or false.
• If the condition is true, one section of code will run.
• If the condition is false, a different section of code
will run.
• Sometimes if the condition is false there is no code
that will run.
Introduction -Topic 1 - 1.43

Selection
• One type of selection is an IF statement.
• The condition compares data. For example:
2 < 3?
The condition is true because 2 is less than 3.

• Another example:
Is 10 = 11?
The condition is false because 10 does not equal 11.
Introduction -Topic 1 - 1.44

Selection – Follow This Algorithm

IF 10 > 20 THEN
Clap your hands
ENDIF
IF 20 = 20 THEN
Stand up
ENDIF
Introduction -Topic 1 - 1.45

Iteration
• To iterate, or reiterate, means to do something more than
once. To repeat.
• Iteration in code is when statements can run multiple times.
• They are often called loops, because the code loops.
• There are two main loops that are used in Python:
• FOR
• WHILE
Introduction -Topic 1 - 1.46

Types of Iteration - FOR


• A for loop runs a set number of times using a counter.
• The counter increases its value each time the loop restarts
(it can also be made to decrease its value if needed).
• For example (pseudocode):
This loop will run 10 times. The
FOR Counter = 0 to 10 first time Counter will be 0.
OUTPUT "Hello" When NEXT Counter is
NEXT Counter reached the Counter has 1
added to it.
The loop stops when Counter is
10
"Hello" will be output 10 times.
Introduction -Topic 1 - 1.47

Test Plan Purpose

• A test plan is a formal document that is used to


document how a program is tested.
• It is important that testing a program:
• Covers all functions
• Includes all inputs
• Includes all process
• Includes all validation
• Includes a range of data
Introduction -Topic 1 - 1.48

Test Plan Structure


Test Description Input Expected Actual
number/ID output output

• Test number/ID is a unique code given to each test. This


allows you to refer to it specifically if needed.
• Description is what you are testing. Which part of the
system and with what type of data.
• Input is the data that you are entering, the options selected
etc. in this test
• Expected output is what the system should do.
• Actual output is what the system actually does.
Introduction -Topic 1 - 1.49

Test Plan Example


• A calculator allows a user to enter numbers, choose to add, subtract,
multiply of divide. The calculator performs the calculation and outputs
the result.
• The test plan shows 3 example tests for addition.
• They test it with different types of additions.
• 1 of the tests did not give the correct output. This is an error in the
program and needs to be fixed.
Test Description Input Expected Actual
number/ID output output
Add1 Addition with 2 1+2 3 3
positive numbers
Add2 Addition with 1 1 + -2 -1 0
positive and 1
negative number
Add3 Addition with two 22 + 35 57 557
2+ digit numbers
Introduction -Topic 1 - 1.50

Quiz

1. What type of language does a computer process?


2. Give ONE (3) feature of the programming language
Python.
3. Identify the 6 stages of the software development lifecycle
and put them in the correct order.
4. Name TWO (2) software engineering principles.
5. Identify THREE (3) ways that you can design a program?
6. Identify the FIVE (5) column headings in a test plan.
Introduction -Topic 1 - 1.51

Topic Summary

• Computers run instructions written in low-level languages


• Humans write programs in high-level languages
• Programs are developed using a Software Development
Lifecycle
• Software Engineering Principles are used to make sure
quality programs are developed
• Programs can be designed using pseudocode algorithm
• Test plans are structured documents used to identify how a
program is tested
Introduction -Topic 1 - 1.52

What Is Next?

In the next topic we will be looking at:


• Installing and using the IDE
• Installing Python
• Interacting with Python
• Command line
• GUI
• Help
Introduction -Topic 1 - 1.53

References

• Boehm, B., (1983). Seven basic principles of software engineering. Journal of


Systems and Software, vol. 3, no.2
• Digital Health (2023). London Ambulance New Year IT failure blamed on
upgrade. Available at:
https://www.digitalhealth.net/2017/06/london-ambulance-new-year-it-failure-blam
ed-on-upgrade/
(Accessed: 21 July 2023)
• Geeks for geeks (no date) (1). Basic principles of good software engineering
approach. Available at:
https://www.geeksforgeeks.org/basic-principles-of-good-software-engineering-ap
proach/
(Accessed: 20 July 2023)
• Geeks for geeks (no date) (2). History of Python. Available at:
https://www.geeksforgeeks.org/history-of-python/ (Accessed: 20 July 2023)
• Python, (2023). Python.org homepage. Available at: https://www.python.org/
(Accessed: 20 July 2023)
Topic 1 – Introduction

Any Questions?

You might also like