





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






















Designed for Beginning university and college learners
Includes Clear explanations • worked examples • review questions • answer key
Edition Independent learning edition • 2026
Original educational material prepared as a general-purpose study resource. It is not affiliated with any university, board, or certification body.
How to Use This Guide
This guide introduces core computer science ideas in a practical order. Read each chapter, rewrite key definitions in your own words, attempt the practice questions without looking at the answers, and then review the answer key.
Study tip: This is a general introductory guide. Course syllabi differ, so compare it with your teacher's outline before relying on it for a specific exam.
Contents
CHAPTER 1
Introduction to Computer Science
Computer science studies computation: how information is represented, processed, stored, communicated, and used to solve problems.
1.1 What is a computer?
A computer is an electronic system that accepts input, processes data according to instructions, stores information, and produces output. A computer system includes hardware, software, data, users, and procedures.
Term Meaning Example
Hardware Physical components you can touch Keyboard, processor, SSD
Software Programs and instructions Web browser, operating system
Data Raw facts represented in a form a computer can process
Numbers, text, images
Input Information supplied to a system Typing a message
Processing Operations performed on input data Calculating a total
Output Results produced by the system A displayed total
Storage Keeping data for later use Saving a document
1.2 Major areas of computer science
1.3 Types of computers and systems
Personal computers are general-purpose devices for individual users. Servers provide services to other devices. Embedded systems control functions inside products such as vehicles and appliances. Mobile devices prioritize portability. High-performance computers are designed for demanding scientific or engineering workloads.
1.4 Information systems and users
A useful system is not just technically correct; it must also fit user needs. Accessibility, reliability, usability, privacy, cost, and maintainability are important design concerns. For example, a school attendance system should protect student records and remain usable by authorized staff.
Chapter summary
Practice questions
2.5 Units and file size
Chapter summary
Practice questions
CHAPTER 3
Algorithms, Logic and Problem Solving
An algorithm is a clear, finite method for producing a result or solving a class of problems.
3.1 Characteristics of a good algorithm
3.2 Problem-solving workflow
A practical workflow is: understand the problem, identify inputs and outputs, break the task into smaller steps, design an algorithm, test it with normal and edge cases, implement it, and improve it after evaluation.
3.3 Pseudocode and flowcharts
Pseudocode describes logic in structured plain language without requiring exact programming syntax. Flowcharts use standard shapes to show actions and decisions. Both help communicate a solution before implementation.
START\nINPUT mark\nIF mark >= 50 THEN\n DISPLAY "Pass"\nELSE\n DISPLAY "Needs improve ment"\nEND IF\nSTOP
3.4 Conditions and Boolean logic
A Boolean value is either True or False. Comparisons such as x > 5 produce Boolean results. AND is true only when both conditions are true; OR is true when at least one condition is true; NOT reverses a Boolean value.
A B A AND B A OR B
False False False False
False True False True
True False False True
True True True True
3.5 Testing and debugging
Testing checks whether software behaves as intended. Debugging finds and fixes causes of incorrect behavior. Test normal inputs, boundary values, invalid inputs, and unexpected situations. For example, a program that accepts ages should be tested with a typical age, zero, a negative number, and non-numeric text if those inputs are possible.
3.6 Example: find the larger of two numbers
INPUT a, b\nIF a > b THEN\n DISPLAY a\nELSE IF b > a THEN\n DISPLAY b\nELSE\n DISP LAY "Both are equal"\nEND IF
CHAPTER 4
Programming Fundamentals with Python
Programming languages let people express algorithms in a form that can be translated or interpreted for execution.
4.1 Variables and data types
A variable is a named reference to a value. Common introductory Python types include int (whole numbers), float (numbers with a fractional part), str (text), and bool (True or False). Choose meaningful variable names and keep values in an appropriate type.
student_name = "Amina"\nage = 19\nscore = 87.5\nis_enrolled = True
4.2 Input, output and conversion
name = input("Enter your name: ")\nscore_text = input("Enter score: ")\nscore = float(score _text)\nprint("Hello", name)\nprint("Score:", score)
The input() function returns text, so convert it when numeric calculation is required. Conversion can fail if the text is not a valid number; robust programs validate user input.
4.3 Operators
Category Examples Purpose
Arithmetic + - * / // % ** Calculations
Comparison == != < <= > >= Compare values
Logical and, or, not Combine conditions
Assignment =, +=, -=, *= Store or update values
4.4 Selection: if / elif / else
temperature = 31\nif temperature >= 35:\n print("Very hot")\nelif temperature >= 25:\n print("Warm")\nelse:\n print("Cool")
Python uses indentation to mark code blocks. Conditions are checked in order; the first matching branch is executed.
4.5 Iteration: loops
for number in range(1, 6):\n print(number)\n\ncount = 3\nwhile count > 0:\n print(cou nt)\n count -= 1
A for loop is useful when iterating over a sequence or known range. A while loop repeats while a condition remains true. Always ensure a while loop can eventually stop.
4.6 Functions
def area_rectangle(width, height):\n return width * height\n\narea = area_rectangle(4, 6 )\nprint(area) # 24
Functions group reusable logic. Parameters receive inputs; return sends a result back to the caller. Small functions with clear names are easier to test and maintain.
4.7 Lists and dictionaries
subjects = ["Programming", "Databases", "Networks"]\nprint(subjects[0])\nsubjects.append("S ecurity")\n\nstudent = {"name": "Amina", "semester": 3}\nprint(student["name"])
Lists store ordered collections and use zero-based indexing. Dictionaries map keys to values. Use a list when sequence matters; use a dictionary when values are naturally looked up by key.
4.8 Common errors
4.9 Worked example: pass or fail
mark = float(input("Enter mark (0-100): "))\nif mark < 0 or mark > 100:\n print("Invalid mark")\nelif mark >= 50:\n print("Pass")\nelse:\n print("Fail")
This example validates the range before checking the pass threshold. In a real assessment system, the pass mark and grading rules must match the relevant institution's policy.
Chapter summary
Practice questions
Notation Common interpretation Example
O(log n) Logarithmic growth Binary search
O(n) Linear growth Scan every item
O(n log n) Linearithmic growth Efficient comparison sorting
O(n²) Quadratic growth Simple nested-loop comparisons
Study tip: Do not assume an algorithm is always fast just because it works on a small example. Consider how time and memory change when the input becomes much larger.
Chapter summary
Practice questions
CHAPTER 6
Databases and SQL
A database stores related information in an organized way so it can be searched, updated, and managed reliably.
6.1 Relational database concepts
A relational database organizes data into tables. A row (record) describes one entity or event; a column (field) describes one attribute. A primary key uniquely identifies each row. A foreign key refers to a key in another table and helps represent relationships.
StudentID StudentName Program
1001 Amina Computer Science
1002 Bilal Information Technology
6.2 Why use a database?
6.3 Basic SQL
SQL is widely used to define, retrieve, and change relational data. The following examples use a table named Students with columns StudentID, StudentName, and Program.
SELECT StudentName, Program\nFROM Students;
Retrieve only students in Computer Science:
SELECT StudentName\nFROM Students\nWHERE Program = 'Computer Science';
Sort by name:
SELECT StudentID, StudentName\nFROM Students\nORDER BY StudentName ASC;
Add a record (the column list and values must match the actual schema):
INSERT INTO Students (StudentID, StudentName, Program)\nVALUES (1003, 'Sara', 'Computer Sci ence');
6.4 Aggregation and grouping
SELECT Program, COUNT(*) AS StudentCount\nFROM Students\nGROUP BY Program;
COUNT counts rows or non-null values depending on the expression. GROUP BY forms groups for aggregate calculations. WHERE filters rows before grouping; HAVING filters groups after aggregation.
6.5 Relationships and normalization
One-to-one relationships connect one record to at most one other record. One-to-many relationships connect one record to multiple records. Many-to-many relationships usually require a junction table. Normalization is a set of design principles that reduces undesirable redundancy and update anomalies.
CHAPTER 7
Computer Networks and the Internet
A network connects devices so they can exchange data and share services.
7.1 Network types
The Internet is a global network of interconnected networks. The World Wide Web is a service that operates over the Internet; it is not the same thing as the Internet itself.
7.2 Network devices
Device Main role
Router Forwards packets between networks
Switch Connects devices within a local network
Wireless access point Provides Wi-Fi connectivity to a network
Modem / terminal equipment Connects a local setup to an access technology, depending on the service
Firewall Applies rules to allow or block network traffic
7.3 IP addresses, DNS and URLs
An IP address identifies a network interface for communication. IPv4 addresses are 32 bits, usually written as four decimal octets. IPv6 uses 128-bit addresses. The Domain Name System (DNS) helps translate domain names such as example.com into records used to locate services.
A URL identifies a resource and commonly includes a scheme (such as https), a host name, and an optional path. HTTPS uses TLS to help protect data in transit between a client and server.
7.4 Packets and protocols
Network data is commonly divided into packets. Protocols define how systems format, send, route, and interpret data. TCP provides a reliable, ordered byte stream; UDP has lower overhead and does not guarantee delivery or ordering. IP handles addressing and routing packets across networks.
7.5 Client-server and peer-to-peer
In the client-server model, a client requests a service from a server. A browser requesting a webpage is a common example. In peer-to-peer systems, devices can act as both clients and providers of resources, depending on the design.
7.6 Network performance
Bandwidth is the capacity of a connection over time. Throughput is the actual achieved data rate. Latency is delay. Packet loss occurs when packets fail to reach their destination. A connection can have high bandwidth but still feel slow for interactive tasks if latency is high.
Chapter summary
Practice questions
8.6 Version control and collaboration
Version control records changes to files over time. It helps teams review modifications, collaborate, create branches, and recover earlier versions. A commit should describe a coherent change. Before sharing a project, remove passwords, API keys, private data, and unnecessary generated files.
8.7 Software quality
Chapter summary
Practice questions
CHAPTER 9
Cybersecurity, Privacy and Responsible
Computing
Cybersecurity reduces the risk of unauthorized access, disruption, theft, and damage. No single tool can eliminate every risk.
9.1 Core security goals
These three goals are often called the CIA triad. Security also includes authentication (proving identity), authorization (deciding permitted actions), accountability, and resilience.
9.2 Common threats
Threat Description Safer response
Phishing Messages imitate trusted sources to steal information
Verify sender and destination; avoid suspicious links
Malware Software designed to harm, spy, or gain unauthorized access
Use trusted sources, updates, and endpoint protection
Ransomware Malware that may encrypt data and demand payment
Maintain tested offline or protected backups
Password reuse One exposed password unlocks multiple accounts
Use unique passwords and a password manager
Social engineering Manipulation intended to bypass normal safeguards
Verify unusual requests through a separate channel
9.3 Practical account protection
9.4 Encryption and hashing
Encryption transforms readable data into ciphertext using a key, allowing authorized decryption. Hashing maps data to a fixed-size digest and is commonly used to check integrity. Passwords should be stored using purpose-built password-hashing algorithms with salts and suitable work factors, not as plain text or with a fast general-purpose hash alone.