Unit 1: Chatbots
Unit 1: Chatbots
Chatbots
There are two main types of chatbots:
● Rule-based chatbots: Have predefined questions built-in, so they are less
conversational, the questions don’t evolve the user’s answer and are limited to the
set questions that have been programmed to be asked
● Chatbots with artificial intelligence: Intelligent conversations as the AI learns from the
user’s answer to guide the next question or offer advice. It is called machine
learning when a device learns over time.
Artificial intelligence
Definition: the ability of a computer system to learn and develop its own programming from
the experiences it encounters
Machine Learning
Definition: the ability of computer systems to learn over time
Data types
Data types Example
String Any text with more than 1 symbol like “Hello world!”
Developing in iteration
When writing programs just like with science or anything else we have a certain way we do
it:
We follow this iterative process:
1. Requirements: Ask what is needed for the program/product to function.
2. Design: Create the algorithm (the steps the computer will follow) with a flowchart or
pseudocode; then check the pseudocode with a trace table.
3. Develop: The program code is written.
4. Test: A structured test plan is used to test if the program is functioning correctly.
5. Review:
● Fix any mistakes identified from the test plan
● Write down possible improvements for the next iteration
● Determine if the program meets the requirements from the start
● Decide if you need to iterate again
6. Launch: Release the final program.
Flowchart
Definition: aka flow diagram is a step-by-step graphical representation of a process, system
or algorithm.
START/ END
PROCESS
INPUT / OUTPUT
DECISION
Example of Python code versus Flowchart:
Python code:
num = int(input(“Enter a number”))
if num > 0:
print(“Greater than 0”)
else:
pass
Errors
Logic The program will run but does not output what is expected; an example of a
errors logic error is the inclusion of an incorrect conditional operator.
Syntax Errors in the program code stop the program from running; an example of a
errors syntax error is where the code has been typed incorrectly, for instance, missing
brackets, colons indentation or incorrect spelling, to name a few.
Runtime Errors occur while the program is running as the instructions cannot be
errors completed; an example of a runtime error is where the variable name has not
been added correctly in one aspect of the program - it would only generate an
error once it is used.
Iteration
Sequence: (normal code - line for line): A series of program instructions.
Selection: (If-else statement)
Iteration: (A loop)
A count-controlled loop is where a series of program instructions is repeated a set number
of times. Also called a for loop.
Iteration as a flowchart and pseudocode
def subtraction(a,b):
z = a-b
if operation == 1:
addition(number1,number2)
elif operation == 2:
subtract(number1,number2)
else:
print("OUT Enter a valid number”)
Arrays
An array is a data structure that can store more than one item of data under a single
identifier (name). In Python, an array can hold only one data type, such as list = [“cat”, “dog”,
“mouse”].
Output:
Software
Application Software
Definition: A software designed to do a particular task.
Example: A word processor, spreadsheet, web browser, games, mobile phone apps
System software
Definition:
- Software that helps a user run a digital device.
- System software can be divided into two categories,
- Operating system
Software that manages all computer or digital devices hardware and software;
it also acts as an interface between computer hardware components and the
user and also provides a platform for which applications run.
- Utility system
Software that helps maintain the smooth functioning of a digital device by
helping the operating system manage tasks and resources
Device drivers
• Software program that operates hardware devices connected to a digital device.
• Plug-and-play devices work on digital devices due to device drivers.
• Some devices require manual installation of device drivers.
Security software
• Use of software like passwords, PINs, biometric systems.
• Implementation of firewalls.
• Use of antivirus, anti-spyware, anti-malware.
Firewalls
A firewall restricts the network traffic entering and exiting a network, to ensure that it is safe.
Antivirus
A software program that protects the computer system from viruses.
Anti-spyware
Software that detects and removes viruses from a computer.
Anti-malware
A software program that protects the computer systems from all malware
Disc defragmentation
• Disk fragmentation: scattered files on disks.
• Defragmentation: rearranging data for efficient storage.
• Used for HDDs for efficient access.
Compression tool
Makes files smaller so they are easier to transfer electronically.
File-management system
Helps the user to create new files and store them on a storage device. Helps users to store
files in separate folders known as directories/folders.
Backup
Creates an exact copy of computer files, which can be used for restoring the original files in
case of file corruption, accidental/intentional deletion, or a disaster.
Security software
Any software that can secure and protect a digital device, e.g., password protection,
biometric security, or anti-malware.
Represent sound
Sound is a pressure wave that causes the air to vibrate.
This fact is used in microphones and speakers.
Sample
Samples are readings that can be taken at specific time intervals and recorded.
Sampling
Sampling is the process of taking samples of a sound.
Amplitude
Amplitude indicates sound volume, with higher values representing louder sound, and is
represented by binary values.
Sample rate
The sample rate, or the number of snapshots taken each second, indicates how many
samples are collected per second.
The sample rate is measured in hertz (Hz), indicating the number of samples taken per
second.
Sample 1 = 100; Sample 2 = 101; Sample 3 = 110; Sample 20 = 011
Bit depth
Bit depth refers to the number of bits used to store each sample. A higher bit depth, along
with more samples taken, results in a better digital sound file.
Data storage
• Binary code - 1s and 0s - stores programs, operating systems, and data.
• Each binary digit (1 or 0) is a bit.
• A processor, made of transistors, is needed for data processing.
• Transistors act as switches to represent 1s and 0s.
• Grouped bits can be processed as larger units within the computer.
Instruction set
● CPU's own set of binary instructions. The instruction set of a CPU is written in binary
(also known as machine code).
Assembly language
● Programmers sometimes write instructions in a more easily understood version of
machine code, called an assembly language.
Interpreter
• Translates each line of HALL code into machine code.
• Carries out one instruction before translating the next, reducing main memory.
• Displays error messages immediately, aiding in debugging.
• Stops program execution when an error is encountered.
• Interprets the program each time, useful for multi-platform applications.
Assembly
• Converting Assembly-Language Instructions to Machine Code
• Creates one line of machine code for each instruction.
• Doesn't convert the entire program in one go.
Compiler
• Translates entire program into machine code.
• Runs program only after all lines are translated.
• Reports code errors at the end, making debugging difficult.
• Takes long to compile, saves copy for reuse.
• Useful for larger programs like computer games.
Registers
Store data about memory locations, instructions and data used during execution of an
instruction. The different registers are:
Accumulator (ACC)
A register used by the ALU to store the results of the processing the ALU carries out
Program counter (PC)
Stores the address of the next instruction waiting to be executed (carried out) by the CPU
Control unit
CU is responsible for coordinating all of the activities of the CPU. For example, it directs the
flow of data between the different components of the CPU, and between the CPU and all
other devices.
Registers
Registers - store data about memory locations, instructions, and data used during the
execution of instructions.
Three stages of CPU cycle
Logic Gates
Conditional operators
Operator Meaning
= equal to
!= not equal to
Application of machine learning
Self-driving cars
● Self-driving cars use data from sensors and the internet to make choices.
● They use this data to find the best route to a destination and avoid obstacles.
Medicine
● Medicine makers use machine learning to predict how illnesses will respond to new
drugs.
● Machine learning can analyse a lot of patient data, like scan images, to help make
accurate diagnoses and create personalised health plans.
Image recognition
● Some software uses facial recognition to let authorized users access digital devices.
● It also helps users organize photographs by content or faces.
Security
● Machine learning analyzes emails and internet activity to quickly alert authorities to
potential threats.
Route calculations
● Satellite navigation systems in cars use data from various sources, like sensors and
real-time traffic information.
● This data helps choose the fastest or most economical route for a journey.
Product targeting
● Many online stores and services collect data about users, such as websites visited,
TV shows watched, and past shopping purchases.
● This data is used to make recommendations for future purchases.
Machine learning and Artificial Intelligence
• Machine learning aids in developing AI devices, like mobile phones, understanding speech
patterns and making text message keyword recommendations.
• Some robots use machine learning for unexpected situations, like industrial settings, using
sensors and AI for safety.
• Machine learning is present in daily digital applications like internet search engines, email
filters, online banking, and biometric security systems.
Computerisation
The range of applications for machine learning and computing technology is far-reaching.
Many traditional manufacturing and industrial practices have also been computerised.
Chatbot
• Manage client-business communications.
• Utilize computing technology for problem-solving.
• Replace traditional staff for customer queries.
Benefits Risks
- The products produced are a better and - Technology can be expensive to purchase
more consistent quality - Costs are unknown-computers need to be
- Computers can work 24/7 repaired if they break down
- There is less chance of injury at work as - Some staff may lose their jobs
fewer humans are involved in the workplace
Prototype
Purpose of Prototypes: Prototypes are created to test new product designs and gather
feedback before finalizing the design.
● Paper-based designs
● Computer-aided design (CAD) representations
● Physical models
● 3D models
User Testing: Prototypes allow designers and developers to test functionality and user
experience.
Decision Making: They help inform decisions on improvements and adjustments needed for
the final product.
Customer Feedback: Sometimes prototypes are shared with potential customers to gather
feedback and identify areas for enhancement.
Unit 3