0% found this document useful (0 votes)
209 views20 pages

First Term Jss 2 Robotics and Ai

Uploaded by

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

First Term Jss 2 Robotics and Ai

Uploaded by

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

FIRST TERM JSS 2 ROBOTICS AND A.

I
Sample curriculum

WEEKS
1. Introduction to Javascript
Definition of Javascrpt
2. Javascript Events
3. Variables and constant in Javascript
4. Javascript operators
5. Javasript control statement (i)
(a) How to use if statement
(b) How to use if-else statement
(c) How to use switch statement
6. Javascript control statement (ii)
(d) How to use tenary operators
(e) How to use for-loop statement
7. Mid term break
8. Introduction to Robotics
Definition of Robot and Robotics
9. Types of Robot
(using A.I stater kits as a case study)
10. Revision
11-13. Examination
WEEK ONE
INTRODUCTION TO JAVASCRIPT
JavaScript is a versatile and widely-used programming language that enables
programmer to create interactive and dynamic web pages, web applications,
and mobile applications.

What is JavaScript?

JavaScript is a high-level, dynamic, and interpreted programming language that


is primarily used for client-side scripting on the web.

Key Features of JavaScript

1. Client-side scripting
2. Dynamic typing
3. Object-oriented
4. First-class functions
5. Prototype-based

Common Uses of JavaScript

1. Web development
2. Game development
3. Desktop applications
4. Server-side programming (with Node.js)

Basic Syntax of JavaScript

1. Variables: let, const, var


2. Data types: numbers, strings, booleans, arrays, objects, null, undefined
3. Operators: arithmetic, comparison, logical, assignment
4. Control structures: if-else, switch, loops (for, while, do-while)
5. Functions: function declarations, function expressions, arrow functions
6. Objects: object literals, constructors, prototypes

Reason for Learn JavaScript?

1. High demand in the job market


2. Versatile and widely-used language
3. Enables you to create interactive and dynamic web pages and applications
4. Essential for web development and mobile app development

How to Get Started with JavaScript

1. Start with basic syntax and data types


2. Practice writing JavaScript code
3. Build small projects and exercises
4. Learn about DOM manipulation and events
5. Explore advanced topics like ES6, React, and Node.js

EVALUATION
1, what is Javascript ?
2. Highlight reasons why we learn Javascript.
3. List four basic concept of Javascript
WEEK TW0
1. Install Visual Studio Code (VS Code)
Make sure you have VS Code installed on your computer.
2. Create a JavaScript File
1. Open VS Code.
2. Create a new file by clicking on File > New File or pressing Ctrl + N.
3. Save the file with a .js extension (e.g., script.js) by clicking on File >
Save As... or pressing Ctrl + S.
3. Write JavaScript Code

console.log('Hello, World!');

JAVASCRIPT EVENT
JavaScript events are actions or occurrences that happen in a web page or
application, such as:

1. Mouse clicks
2. Key presses
3. Page loads
4. Form submissions
5. Hovering over elements
6. Touch events (on mobile devices)

Events are used to trigger functions or code execution in response to user


interactions or changes in the application state.

Common JavaScript Events

1. click
2. hover
3. submit
4. change
5. keydown
6. load
7. scroll
8. resize
9. touchstart
10. touchmove

Event Listeners

To respond to events, you attach an event listener to an element or object. The


event listener is a function that will be executed when the event occurs.

Example:
// Add an event listener to a button element
document.getElementById('myButton').addEventListener('click', function() {
console.log('Button clicked!');
});

Event Object

When an event occurs, an event object is passed to the event listener function.
The event object contains information about the event, such as:

1. type (event type)


2. target (element that triggered the event)
3. currentTarget (element that the event listener is attached to)
4. preventDefault() (method to prevent default browser behavior)

Example:

// Log event object properties


document.getElementById('myButton').addEventListener('click',
function(event) {
console.log(event.type); // "click"
console.log(event.target); // button element
});

Event Propagation
Event propagation in JavaScript refers to the process by which an event travels
through the Document Object Model (DOM) tree, allowing multiple elements
to respond to the same event.

There are two phases of event propagation:

1. Capturing phase: The event propagates from the top-most element (window)
down to the target element.
2. Bubbling phase: The event propagates from the target element up to the top-
most element (window).

During event propagation, the event object is passed to each element's event
listener function, allowing them to respond to the event.

Methods of Event Propagation

1. stopPropagation(): Stops the event from propagating further.


2. stopImmediatePropagation(): Stops the event from propagating further and
prevents other event listeners on the same element from being executed.
Examples Event Propagation
1. Clicking a button inside a div: The click event propagates from the button
(target) to the div (ancestor) and then to the window (top-most element).
2. Hovering over a link inside a paragraph: The hover event propagates from
the link (target) to the paragraph (ancestor) and then to the window (top-most
element).

Why is Event Propagation Important?

1. Allows multiple elements to respond to the same event.


2. Enables event delegation (handling events on a parent element instead of
individual child elements).
3. Helps prevent duplicate event handling.
Event propagation can be controlled using stopPropagation() or
stopImmediatePropagation() methods.

EVALUATION
1. States examples of event propagation
2. List five Javascript common events
3. Explain the term event object
WEEK THREE
Variables and constants in JavaScript
Variables
In JavaScript, a variable is a container that holds a value. It can be considered
as a labeled box where data or value can be stored .

How variable can be used in Javascript


1. Declare a variable using let, const, or var.
2. Assign a value to a variable using the assignment operator (=).
3. Use the variable name to access its value.

Example:
let name = 'John';
console.log(name); // Output: John
Constants
A constant is a variable whose value cannot be changed once it's declared.
How variable can be used in Javascript
1. Declare a constant using const.
2, Assign a value to a constant using the assignment operator (=).
3. Trying to reassign a value to a constant will result in an error.
Example:
const PI = 3.14;
console.log(PI); // Output: 3.14
PI = 2.71; // Error: Assignment to constant variable.
Key differences between variables and constants
1. Variables can be reassigned, while constants cannot.
2. Constants are immutable, while variables are mutable.
Best practices on how to handle constant in javascript
1. Use const for values that don't change, like configuration settings or
mathematical constants.
2. Use let for values that change, like user input or temporary calculations.
3. Avoid using var unless you need to support older browsers.
EVALUATION
1. Differentiate berween variable and constant in Javascript
2. How can variable be used in Javascript
3. Write a simple javascript progtam to declare PI as maths constant
statement

WEEK FOUR
Javascript operators

JavaScript operators are symbols used to perform operations on values and


variables. Here are the main categories of JavaScript operators:

1. Arithmetic Operators
- + (Addition)
- - (Subtraction)
- * (Multiplication)
- / (Division)
- % (Modulus)
- ** (Exponentiation)

2. Assignment Operators

- = (Assignment)
- += (Addition Assignment)
- -= (Subtraction Assignment)
- *= (Multiplication Assignment)
- /= (Division Assignment)
- %= (Modulus Assignment)

3. Comparison Operators

- == (Equal)
- != (Not Equal)
- === (Strict Equal)
- !== (Strict Not Equal)
- > (Greater Than)
- < (Less Than)
- >= (Greater Than or Equal)
- <= (Less Than or Equal)

4. Logical Operators

- && (Logical And)


- || (Logical Or)
- ! (Logical Not)

5. Bitwise Operators

- & (Bitwise And)


- | (Bitwise Or)
- ^ (Bitwise Xor)
- ~ (Bitwise Not)
- << (Left Shift)
- >> (Right Shift)
- >>> (Unsigned Right Shift)

6. String Operators

- + (Concatenation)
7. Ternary Operator

- ?: (Conditional Operator)

Simple practical uses of JavaScript operators:

1. Arithmetic Operators

- Calculate the area of a rectangle: let area = length * width;


- Calculate the sum of two numbers: let sum = num1 + num2;

2. Assignment Operators

- Increase a value by 5: let count = 0; count += 5;


- Double a value: let num = 10; num *= 2;

3. Comparison Operators

- Check if a user is 18 or older: let age = 20; if (age >= 18)


{ console.log("Adult"); }
- Check if a value is equal to 5: let num = 5; if (num === 5)
{ console.log("Equal"); }

4. Logical Operators

- Check if a user is 18 or older and has a valid ID: let age = 20; let hasId =
true; if (age >= 18 && hasId) { console.log("Allowed"); }
- Check if a value is either 5 or 10: let num = 5; if (num === 5 || num ===
10) { console.log("Valid"); }

5. String Operators

- Concatenate two strings: let greeting = "Hello, " + "World!";

6. Ternary Operator

- Simplify an if-else statement: let age = 20; let status = age >= 18 ?
"Adult" : "Minor";
EVALUATION
1. Write three examples of assignment operators
2. Give five examples of bitwise operators
WEEK FIVE
Javasript control statement (i)
(a) How to use if statement
(b) How to use if-else statement
(c ) How to use switch statement

Control statements in programming that are used to control the flow of a


program's execution. They determine the order in which statements are
executed, allowing the program to make decisions, repeat tasks, and skip
over certain code.

Types of control statements

1. Conditional Statements:
- If-else statements: Execute code based on a condition.
- Switch statements: Execute code based on a value.
2. Loops:
- For loops: Repeat code for a specified number of iterations.
- While loops: Repeat code while a condition is true.
- Do-while loops: Repeat code while a condition is true, with a guaranteed
first iteration.
3. Jump Statements:
- Break statements: Exit a loop or switch statement.
- Continue statements: Skip to the next iteration of a loop.
- Return statements: Exit a function and return a value.
4. Exception Handling:
- Try-catch statements: Catch and handle runtime errors.

Functions of Control statements


1. Make decisions based on conditions
2. Repeat tasks
3. Skip over code
4. Handle errors

How to use if statement in Javascript


If Statement

1. Start with the if keyword.


2. Follow with a condition in parentheses ().
3. Write the code to be executed if the condition is true inside curly braces {}.

Example

let age = 25;


if (age >= 18) {
console.log("You are an adult!");
}

How to use if-else statement in Javascript

If-Else Statement

1. Add the else keyword after the if statement.


2. Write the code to be executed if the condition is false inside curly braces {}.
Example
let age = 15;
if (age >= 18) {
console.log("You are an adult!");
} else {
console.log("You are a minor!");
}

Else If Statement
1. Add the else if keyword after the initial if statement.
2. Follow with another condition in parentheses ().
3. Write the code to be executed if the second condition is true inside curly
braces {}.
Example
let age = 25;
if (age >= 18) {
console.log("You are an adult!");
} else if (age >= 13) {
console.log("You are a teenager!");
} else {
console.log("You are a kid!");
}

Guideline
- Use parentheses around the conditions.
- Use curly braces around the code blocks.
- Keep the conditions and code blocks indented for readability.
How to use switch statement in Javascript
The switch statement in JavaScript is used to execute different blocks of code
based on the value of a variable or expression. Here's the basic syntax:

switch (expression) {

case value1:

// code to be executed if expression equals value1

break;
case value2:

// code to be executed if expression equals value2

break;

default:

// code to be executed if expression doesn't match any case

Example:

let day = 2;

switch (day) {

case 1:

console.log("Monday");

break;

case 2:

console.log("Tuesday");

break;

default:

console.log("Another day");

In this example, the switch statement checks the value of the day variable. If it's
1, it logs "Monday". If it's 2, it logs "Tuesday". If it's neither 1 nor 2, it logs
"Another day".
Guideline
- Use break statements to exit the switch block after executing the matching
case.
- Use the default case to catch values that don't match any other case.
- You can also use strings, booleans, or even expressions as case values.
Step-by-step guide on how to use switch statements in JavaScript:
1. Start with the switch keyword followed by the expression in parentheses ().
2. Add case clauses for each value you want to check, followed by a colon :.
3. Write the code to be executed for each case inside the case clause.
4. Use the break statement to exit the switch block after executing the matching
case.
5. Add a default clause to catch values that don't match any case.
Example:
let color = 'red';
switch (color) {
case 'red':
console.log('The color is red');
break;
case 'blue':
console.log('The color is blue');
break;
default:
console.log('The color is not red or blue');
}

In this example
- The switch statement checks the value of the color variable.
- If color is 'red', it logs 'The color is red'.
- If color is 'blue', it logs 'The color is blue'.
- If color is neither 'red' nor 'blue', it logs 'The color is not red or blue'.
Guideline
- Use break statements to avoid executing multiple cases.
- Use the default clause to handle unexpected values.
- Keep the switch block organized and readable.
EVALUATION
1. What is control statement ?
2. State how to use If-Else statement in Javascript
3. Write the code to be executed if the second condition is false inside curly
braces {}.
WEEK SIX
Javascript control statement (ii)
(d ) How to use tenary operators
(e ) How to use for-loop statement

How to use tenary operators


Ternary operator in JavaScript is a concise way to write a simple if-else
statement. It consists of three parts:

1. Condition: A boolean expression to be evaluated.


2. True value: The value to be returned if the condition is true.
3. False value: The value to be returned if the condition is false.
The syntax is:
condition ? trueValue : falseValue;
Example:
let age = 25;
let status = age >= 18 ? "Adult" : "Minor";
In this example:
- The condition is age >= 18.
- If the condition is true, the true value "Adult" is assigned to the status
variable.
- If the condition is false, the false value "Minor" is assigned to the status
variable.
Ternary operators can be used to simplify simple if-else statements, making
your code more concise and readable.

Some more examples


- let isAdmin = user.role === "admin" ? true : false;
- let message = isEmpty ? "Please fill in the field" : "Field is valid";
Step-by-step guide on how to use ternary operators
1. Identify a simple if-else statement that can be simplified.
2. Replace the if-else statement with the ternary operator syntax: condition ?
trueValue : falseValue;
3. Write the condition (a boolean expression) before the ? symbol.
4. Write the true value (the value to be returned if the condition is true) after
the ? symbol.
5. Write the false value (the value to be returned if the condition is false)
after the : symbol.

Example:
let age = 25;
let status = age >= 18 ? "Adult" : "Minor";

Breakdown:
- age >= 18 is the condition.
- "Adult" is the true value.
- "Minor" is the false value.

Guideline
1. Use ternary operators for simple if-else statements.
2. Keep the condition, true value, and false value concise.
3. Use parentheses for clarity if needed.
More examples:
- let isAdmin = user.role === "admin" ? true : false;
- let message = isEmpty ? "Please fill in the field" : "Field is valid";
- let result = num > 0 ? "Positive" : num < 0 ? "Negative" : "Zero"; (nested
ternary operator)

How to use for-loop statement


The for-loop statement in JavaScript is used to execute a block of code
repeatedly for a specified number of times. Here's the basic syntax:

for (initialization; condition; increment) {

// code to be executed

Let's break it down:

1. Initialization: Typically used to set the starting value of a counter variable.


2. Condition: Evaluated before each iteration. If true, the loop continues.
3. Increment: Updates the counter variable after each iteration.

Example:

for (let i = 0; i < 5; i++) {

console.log(i);

Output: 0, 1, 2, 3, 4

In this example:

- let i = 0 initializes the counter variable i to 0.


- i < 5 is the condition. The loop continues as long as i is less than 5.
- i++ increments i by 1 after each iteration.
Guideline
1. Use let or var to declare the counter variable.
2. The condition can be any boolean expression.
3. The increment can be i++, i--, i += 2, etc.

Step-by-step guide on how to use for-loop statements in JavaScript


1. Initialization: Declare a counter variable and set its initial value.

let i = 0;

2. Condition: Specify a boolean expression to determine when to stop the loop.

i < 10

3. Increment: Update the counter variable after each iteration.

i++

4. Loop body: Write the code to be executed inside the loop.

console.log(i);

5. Combine: Put it all together inside the for statement.

for (let i = 0; i < 10; i++) { console.log(i); }

Example: Print numbers from 0 to 9

for (let i = 0; i < 10; i++) { console.log(i); }

Output: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Tips on guideline
1. Use let or var to declare the counter variable.
2. Adjust the initialization, condition, and increment to fit your needs.
3. Use break to exit the loop prematurely.
4. Use continue to skip to the next iteration.
EVALUATION
1. List three parts of tenary operators .
2. What is the output of the program below
for (let i = 0; i < 5; i++) {

console.log(i);

Output:
WEEK SEVEN
MID-TERM BREAK
WEEK EIGHT
Introduction to Robotics
Definition of Robot and Robotics
Robotics is a multidisciplinary field that combines engineering, computer
science, and mathematics to design, build, and operate robots. Here's an
introduction to robots and robotics:
What is a Robot?
A robot is a programmable machine that can perform tasks autonomously or
semi-autonomously, often with human-like capabilities. Robots can be physical
(hardware) or virtual (software).
Types of Robots
1. Industrial Robots: Used in manufacturing and production.
2. Service Robots: Assist humans in various tasks, like cleaning, cooking, and
healthcare.
3. Autonomous Robots: Self-navigating robots, like drones and self-driving
cars.
4. Humanoid Robots: Designed to resemble and mimic human appearance and
movement.
5. Social Robots: Interact with humans, like chatbots and virtual assistants.

Robotics Subfields
1. Artificial Intelligence (AI): Enables robots to learn, reason, and make
decisions.
2. Machine Learning (ML): Allows robots to improve performance through
data analysis.
3. Computer Vision: Enables robots to interpret and understand visual data.
4. Robotics Engineering: Focuses on designing, building, and operating robots.
5. Human-Robot Interaction (HRI): Studies how humans interact with robots.

Robotics Applications
1. Manufacturing and Production
2. Healthcare and Medicine
3. Transportation and Logistics
4. Service and Hospitality
5. Space Exploration
6. Military and Defense
7. Agriculture and Environment

Benefits of Robotics
1. Increased Efficiency
2. Improved Accuracy
3. Enhanced Productivity
4. Augmented Human Capabilities
5. Improved Safety

Robotics Challenges
1. Technical Complexity
2. Ethical Concerns
3. Job Displacement
4. Safety and Security
5. High Development Costs

EVALUATION
1. What is Robot and Robotics ?
2. States five benefits of Robotics
3. List five applications of Robotics to the society
WEEK NINE
Types of Robots
1. Industrial Robots: Used in manufacturing, assembly, and production.
Examples include welding robots, painting robots, and assembly line robots.

2. Service Robots: Assist humans in various tasks, such as:


- Domestic Robots: Vacuum cleaning, lawn mowing, and cooking robots.
- Healthcare Robots: Nursing robots, surgery assistance robots, and
rehabilitation robots.
- Hospitality Robots: Food serving robots, cleaning robots, and customer
service robots.

3. Autonomous Robots: Self-navigating robots, including:


- Drones: Unmanned aerial vehicles (UAVs) for surveillance, delivery, and
photography.
- Self-Driving Cars: Autonomous vehicles for transportation and logistics.

4. Humanoid Robots: Designed to resemble and mimic human appearance and


movement, such as:
- Androids: Robots with human-like features and capabilities.
- Cobots: Collaborative robots that work alongside humans.

5. Social Robots: Interact with humans, including:


- Chatbots: Virtual assistants for customer service and support.
- Companion Robots: Robots for entertainment, education, and companionship.

6. Agricultural Robots: Used in farming and agriculture, such as:


- Harvesting Robots: Automated harvesting and crop monitoring robots.
- Livestock Robots: Robots for animal care and monitoring.

7. Military and Defense Robots: Used for surveillance, explosive disposal, and
combat, including:
- Drone Swarms: Coordinated groups of drones for surveillance and attack.
- Battlefield Robots: Robots for explosive disposal and combat support.

8. Space Exploration Robots: Used for planetary exploration and research, such
as:
- Rovers: Robots for planetary surface exploration.
- Satellites: Robots for orbital research and surveillance.

9. Swarm Robots: Large groups of simple robots that work together, such as:
- Nano-Robots: Tiny robots for medical and environmental applications.
- Flocking Robots: Robots that mimic bird flocking behavior.

10. Hybrid Robots: Combine different robot types, such as:


- Wheeled- Legged Robots: Robots with both wheels and legs for versatile
mobility.

EVALUATION
State and explain any five types of Robots

You might also like