Docsity

Computer science 9 class notes, Study notes of Computer science

Toggle sidebar
bg1
Programming Languages — Page 1
PROGRAMMING LANGUAGES
Complete Easy Notes: Python • HTML • C++ • JavaScript
Definitions • Concepts • Syntax • Examples • Code • Comparison • Practice
A beginner-friendly study guide designed for learning and exam revision.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13

Partial preview of the text

Download Computer science 9 class notes and more Study notes Computer science in PDF only on Docsity!

PROGRAMMING LANGUAGES

Complete Easy Notes: Python • HTML • C++ • JavaScript

Definitions • Concepts • Syntax • Examples • Code • Comparison • Practice

A beginner-friendly study guide designed for learning and exam revision.

Table of Contents

1. What is a Programming Language?

2. Programming Basics

3. Types of Programming Languages

4. Python

5. HTML

6. C++

7. JavaScript

8. Comparison of Python, HTML, C++ and JavaScript

9. Common Programming Concepts

10. Errors and Debugging

11. Algorithms and Flowcharts

12. Mini Projects

13. Practice Questions

14. Quick Revision Sheet

2. Programming Basics

Source code

Source code is the human-readable code written by a programmer.

Compiler

A compiler translates a program into machine or lower-level code before it is run.

Interpreter

An interpreter generally reads and executes program instructions during execution.

Variable

A variable is a named place used to store a value.

name = "Ali" age = 17 print(name) print(age)

Data types

Common data types include integer (whole number), float (decimal number), string (text), Boolean

(True/False), list/array, and object.

Operators

Arithmetic: +, -, *, /, %, //, **. Comparison: ==, !=, >, <, >=, <=. Logical: and, or, not.

Conditional statements

age = 18 if age >= 18: print("Adult") else: print("Under 18")

Loops

A loop repeats a block of code.

for i in range(5): print(i)

Function

def add(a, b): return a + b

print(add(3, 4))

3. Types of Programming Languages

Low-level languages

Machine language uses binary instructions. Assembly language uses symbolic instructions closer to

hardware.

High-level languages

High-level languages are easier for humans to read and write. Python, C++, Java and JavaScript are

examples.

Procedural programming

Programs are organized around procedures or functions that perform steps.

Object-oriented programming (OOP)

Programs are organized around objects and classes. C++ and Python support OOP.

Scripting languages

Scripting languages are commonly used for automation and web behavior. JavaScript and Python are

widely used this way.

Markup language

HTML is a markup language, not a general-purpose programming language. It describes the structure of

web pages.

Python class

class Student: def init(self, name): self.name = name

def show(self): print(self.name)

s = Student("Ali") s.show()

Python advantages

  • Readable syntax
  • Large ecosystem
  • Useful for beginners
  • Cross-platform
  • Many libraries and frameworks

5. HTML

Definition: HTML stands for HyperText Markup Language. It is used to structure content on web pages.

HTML uses elements/tags such as headings, paragraphs, links, images, lists, tables and forms.

Basic HTML document

My Page

Hello World

This is my first web page.

Common HTML tags

Tag Purpose

Main heading

Paragraph

Link

Image

/ Lists

Table

Form

Line break

HTML link and image

Visit site

HTML form

Name:

Submit

HTML provides structure; CSS is commonly used for styling; JavaScript is commonly used to add behavior

and interactivity.

s.name = "Ali"; s.show(); }

C++ uses

  • Systems and performance-focused software
  • Games and graphics
  • Embedded and hardware-related software
  • Desktop applications
  • Competitive programming and learning algorithms

7. JavaScript

Definition: JavaScript is a programming language widely used to make web pages interactive and to build

applications in browsers and on servers.

Basic JavaScript

let name = "Sara"; let age = 17;

console.log(name); console.log(age);

Condition

let marks = 80;

if (marks >= 50) { console.log("Pass"); } else { console.log("Fail"); }

Loop

for (let i = 1; i <= 5; i++) { console.log(i); }

Function

function add(a, b) { return a + b; }

console.log(add(4, 5));

JavaScript with HTML

Click me

DOM

The Document Object Model (DOM) represents a web page as objects. JavaScript can use the DOM to

read or change page content, attributes and styles.

document.getElementById("title").textContent = "New Heading";

JavaScript uses

  • Interactive websites
  • Web applications

8. Python vs HTML vs C++ vs JavaScript

Technology Main role Typical strength

Python Programming language Readable general-purpose programming, automation, data/AI

HTML Markup language Web-page structure

C++ Programming language Performance and systems/software development

JavaScript Programming language Web interactivity and applications

Important: HTML is not technically a programming language; it is a markup language. CSS is a stylesheet

language used mainly for presentation.

9. Common Programming Concepts

Algorithm

An algorithm is a finite, ordered set of steps used to solve a problem.

Example algorithm: add two numbers

1. Start

2. Input first number

3. Input second number

4. Add the two numbers

5. Display the result

6. Stop

Flowchart

A flowchart is a diagram that represents the steps of an algorithm using standard symbols.

Common flowchart symbols

  • Oval: Start/End
  • Parallelogram: Input/Output
  • Rectangle: Process
  • Diamond: Decision
  • Arrows: Flow direction

Input, processing and output

Input is data supplied to a program. Processing is the work performed on that data. Output is the result

produced by the program.

Comments

Comments explain code and are ignored as instructions by the language processor.

Libraries

A library is reusable code that provides functions or tools for programmers.

11. Algorithms and Flowcharts: Example

Problem: Find the larger of two numbers

Algorithm:

1. Start

2. Input A and B

3. Compare A and B

4. If A > B, display A

5. Otherwise display B

6. Stop

Python solution

a = int(input("A: ")) b = int(input("B: "))

if a > b: print(a) else: print(b)

C++ solution

#include using namespace std;

int main() { int a, b; cin >> a >> b;

if (a > b) cout << a; else cout << b;

return 0; }

12. Mini Projects

Project 1: Python calculator

a = float(input("First number: ")) op = input("Operator (+ - * /): ") b = float(input("Second number: "))

if op == "+": print(a + b) elif op == "-": print(a - b) elif op == "*": print(a * b) elif op == "/": if b != 0: print(a / b) else: print("Cannot divide by zero") else: print("Invalid operator")

Project 2: Simple HTML page

Student Page

My Introduction

My name is Ali. I am learning programming.

Learn more

Project 3: JavaScript counter

let count = 0;

function increase() { count++; document.getElementById("count").textContent = count; }

Project 4: C++ marks checker

#include using namespace std;

int main() { int marks; cin >> marks;

if (marks >= 50) cout << "Pass"; else cout << "Fail";

return 0; }

14. Quick Revision Sheet

Programming language: A formal language used to give instructions to a computer.

Python: General-purpose language with readable syntax; widely used in automation, data and AI.

HTML: Markup language used to structure web pages.

C++: General-purpose compiled language known for performance and broad programming support.

JavaScript: Programming language widely used for interactive web pages and applications.

Variable: Named storage for a value.

Function: Reusable block of code.

Loop: Repeats instructions.

Condition: Makes a decision based on a test.

Algorithm: Step-by-step method for solving a problem.

Debugging: Finding and fixing program errors.

Syntax error: Code violates language rules.

Runtime error: Error during execution.

Logic error: Program runs but gives a wrong result.

Study Tip

Learn the meaning first, then understand the small examples. Do not try to memorize every line of code at

once. Practice changing variable names, values and conditions to see how the program behaves.